solved

solved
Last edited on
Regarding your syllable function.

Your main() opens the file. Then count() reads the entire file until eof. Then, you pass the same stream
to syllablecount() which reads the entire file until eof. But count() already read to eof, so syllable
count will do nothing, since instream.eof() is true the first time through.

Regarding counting word length.

Because you read a character at a time, your only real option is to keep a counter of the number of
letters in the current word. The counter increments by one any time it sees a letter. The counter
is reset to zero when it sees a space or a punctuation mark such as '.' or '?' or '!'. Before resetting
to zero (to begin a new word), check to see how many letters were in the previous word.
I got the word count working, but the syllables I'm still having trouble with. I put the syllable count back within the function that counts everything else, so it shouldn't be at eof now. Any more tips?
Notice you have a semicolon after the if( next == .... ) so syllablecount is incremented all the time.
Topic archived. No new replies allowed.