read txt increment words

I am workng on a progam to read txt in a file and print it to the screen. Every fifth word I sub an underline till eof. I have to read in each char. My issue is that I need to compare the present value with the last read. If present value is a char and previous value is not a char I have a new word and can increment my counter. At the fifth word I sub a constant string" ___________"
I am using wordCount % 5 = 0 to activate and so my count doesn't need to reset a count control loop.
<inFile.get (ch);

while (inFile)

cout << ch << endl;
inFile.get (ch);

if(isalpha(ch))
{
cout << ch << endl;
}


inFile.clear();
inFile.close();>
have a char last, before inFile.get(ch), swap(last, ch).
Topic archived. No new replies allowed.