Access File Program

Need to write a program that displays the number of letters that are stored in a file, but I have no idea how to and haven't been able to find a way online. It seems very simple but I just don't know what to do.

while ( in >> c ) if ( isalpha( c ) ) counter++;
(c being a char)
Last edited on
What does this specific line of code do?
It reads non-blank characters one-by-one from an input filestream named 'in' (which you will have previously attached to a file) and, if they are alphabetic, increments a counter.

It will stop the loop when the filestream tests as 'bad' (because it has run out of characters).

YOU have to write about five or six not-very-exciting lines of code around that to:
- open the filestream
- declare c as char
- declare counter as an int and initialise it to 0

- output the value of counter at the end.

That's it.
Last edited on
Topic archived. No new replies allowed.