No, it does not appear to be correct. But part of computer
science is learning how to form a hypothesis and run an experiment to test that hypothesis. For example, given a file that contains "A,a" (uppercase A, comma, lowercase A), what do you want the output of your program to be?
Based on your description, it should print
(It's not clear if it should print 0 for all the other letters.)
isgraph is found in the <cctype> header, so it should be #include'd as well. Perhaps you should be using isalpha instead.
Other things:
- Your sample text expects the user to enter a filename, but your program does not do this.
- Your sample text counts letters A-Z; your program appears to track every printable character, and is case sensitive.
- To avoid case-sensitivity, you could convert every character to uppercase with toupper.