Hi, i have to write a program: user inputs a string of characters (letter, digits spaces etc any possible charachter) and then the program should calculate how many letter, digits, spaces, and other characters are there.
I did this question using just a char array and then for loop with a switch, like 100 cases: case 'A': case 'a' and all the way to the end of alphabet, and then count++; break; case 1, case 2 etc case 10, another count; break; so program is very long. Then i saw that i can use ctype.h, so i input a string of w.e., then something like that:
for (i=0; i<50; i++)
{
c=isalpha (string[i]);
if (c!=0])
{
alpha++;
}
}
from my understanding, if the first character is a letter then c is gonna be something but 0, is its not a letter then its gonna be 0
but for some reason it doesnt work.
Any help would be appreciated.