#include <stdio.h> int main() { int up = 0, low = 0, num = 0, space = 0, oth = 0, i = 0; char *p, s[20]; printf("input the string:"); while ((s[i] = getchar()) != '\n') i++; p = &s[0]; while (*p != '\n') { if (('A' <= *p) && (*p <= 'Z')) { up++; } else if (('a' <= *p) && (*p <= 'z')) { low++; } else if (*p == ' ') { space++; } else if ((*p >= '0') && (*p <= '9')) { num++; } else { oth++; } p++; } printf("up:%d low:%d space:%d num:%d oth:%d", up,low,space,num,oth); }