Teen Programmers Unite  
 

 

Return to forum top

Reading text files in C++

Posted by PavalDaniel [send private reply] at March 13, 2002, 01:36:10 PM

I know how to read a file character by character and line by line, but not WORD by WORD. Does anybody have an idea how to do that?

Posted by taubz [send private reply] at March 13, 2002, 02:19:43 PM

You have to work it out yourself. If you know how to read character by character, then you already have the knowledge to do it.

- taubz

Posted by CodeRed [send private reply] at March 13, 2002, 02:22:58 PM

umm, can't think of it in C++ but in Java you would just parse it using the stringTokenizer class

Posted by gian [send private reply] at March 13, 2002, 10:47:48 PM

HINT: Read character by character until you find a space!

Posted by RedX [send private reply] at March 14, 2002, 01:56:07 PM

Ever heard of Yakk and Bizon? These tools allow you to create parsers without too much trouble. I'm sure these are easy to find.

RedX

Posted by gian [send private reply] at March 14, 2002, 02:01:32 PM

RedX: But those are overkill for what is needed here... a simple strtok() would seperate them, or just reading char by char until you hit a space.

Posted by RedX [send private reply] at March 15, 2002, 01:11:29 PM

I thought they were worth mentioning. In case he was planning on doing recognition-thingies with it.

RedX

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.