Ok We are doing the basic I/O problems where you count the words, line and characters in a text file along with some other stuff.
With counting words I have it checking for spaces but it doesn't find a space at the end of the line so it doesn't count that last word.
So if I have something likeCode:if(myInFile.is_open()){ while(getline(myInFile, theText)){ //myInFile >> word; lineCount++; for(int i = 0; i < theText.length(); i++){ ch = theText[i]; if(isspace(ch)) wordCount++; cout << "char: " << ch << endl; } } }
The Dog ran away
Yesterday he came back.
It will only count 6 words. It will not count the words away and back.
Thanks for any help.



LinkBack URL
About LinkBacks



