Hey there everyone! I found this site because I was looking for some help with my c++ course. I am trying to figure out how to make a program that can read in data from a .txt and then replace every 7th word with an underscore. It must print out the text twice; once without the blanks and once with the blanks.
I know what I need to do essentially, but I just don't know how to do it. I can get it to print the text from the file but I can't get it to count the words correctly (thus not being able to replace any words). The problem I am having is that I cannot assume that there is a space in front of a word (ie: "This sentence has 11 words,but it will only count 10.")
Also on the first text print it adds another period (or last char). How do I get it to not repeat that?
I have:
while(inFile)
{ inFile.get(ch);
cout << ch;
}