Can be solved with the following code: #include <stdio.h> #include <string.h> int main() { char str[100]; int i; int letters = 0; int space = 0; int digits = 0; int others = 0;
printf("输入一行字符:");
gets(str);
for (i = 0; str[i] != '\0'; i++) {
if ((str[i] >= 'a' &&