ace
2013-03-21 21:43:20 UTC
I'm supposed to write a program to read a text file and display the following:
a) alphabetic letters //finished with
b) digits // finished with
c) other characters that are not alphabetic letters and not digits //finished with
d) total characters read //need help
The total characters part confused me. Does it mean to count all of the alphabetic letters + other characters or does it want me to count alphabetic letters + digits + other characters??
If so, how would I implement the code into this while loop?
while ((curCh = fgetc(sp1)) != EOF)
{
if (isalpha(curCh))
countCh++;
else if (isdigit(curCh))
digits++;
else
countAllOtherCh++;
}
Also, thanks to @unfaithful for helping me earlier.