|
| karma4561 (7) | |||
| Hi. I'm trying to read words from a .txt file in the following format: wordA wordB wordC and so on. What I would like to do is to count the words that are in the text file. To do that I used the following code:
In this way, each time that C++ find a new line it increment the value of numberOfWords, and when the file reach the end, it stop and I have the number of words. I have to do the same thing, but without the getline() method, in fact, with any method that do not receive a string as parameter. Best Regards. | |||
| tomao (31) | |
| the only alternative I know would be the extraction operator. For example: file >> dump; | |
| karma4561 (7) | |
| Thanks!, I already did it, I used the getline that is in the stream class Regards, | |
This topic is archived - New replies not allowed.
