You should not be doing while (!myfile.eof()) -- here's why (feof() and .eof() are identical)
After you've read all the lines in the loop, what do you expect getchar() to read?
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Hi:
Thanks for ur reply.
Are you saying that i should use feof instead of eof ? I am not sure.
If they are identical, what do you think? You need to look in your text how to loop through a file.The other thing is I am not sure what I can do about that getchar. I am positive that what I have in my code is wrong. All I am able to see is that if there is a space, i should increment the counter by 1.
Good, you know there is a problem. That's better than some others I've seen.
You need to think about what you are attempting to do. What designates the end of a word? What indicates the end of a line? Maybe in your loop instead of reading each line you could read each character looking for and counting these indicators.
See what you can do with that idea.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944