Alternative option to getline

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:

1
2
3
4
5
6
string dump;
  while (file.eof() == false){
   getline(file,dump);
   numberOfWords++;
}


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.
the only alternative I know would be the extraction operator.
For example:
file >> dump;
Thanks!, I already did it, I used the getline that is in the stream class

Regards,
Topic archived. No new replies allowed.