program to determine amount of lines, words, and letters in a text file.

Hi guys,

Sorry to bother everybody, but I'm afraid I'm here again asking for advice. I need to make a program to count how many lines, words and letters are in a text file. I really don't know where to start with this. If somebody could give me a few pointers on how to do it, I would be very grateful.

Thanks :)
Start off by reading the file character by character.

If the character is alphanumeric, add one to letters.

If the character is a space, add one to the variable that holds the number of words. ( You can also add some checking to make sure multiple spaces are present and counted as words )

If the character is a newline, add one to the # of lines.

Read in the whole file.

For alphanumeric checking look here:
http://www.cplusplus.com/reference/clibrary/cctype/


Topic archived. No new replies allowed.