1 void StringCount(char s[]) 2 { 3 int letter, blank, digit, other; 4 5 letter = 0; 6 blank = 0; 7 digit = 0; 8 other = 0; 9 10 int i = 0; 11 while (s[i] != '') //字符串都是''结尾的 12 { 13 if ((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z')) 14 { 15 letter++; 16 } 17 else if (s[i] == ' ' || s[i] == ' ') 18 { 19 blank++; 20 } 21 else if (s[i] >= '0' && s[i] <= '9') 22 { 23 digit++; 24 } 25 else 26 { 27 other++; 28 } 29 30 i++; 31 } 32 33 printf("letter = %d, blank = %d, digit = %d, other = %d ", letter, blank, digit, other); 34 }