#include
int main(){
int space=0,number=0,others=0;
char str[1000];
char nextchar = 0;
printf("输入任意文字:\n");
scanf("%s", str);
printf("输入内容:%s\n", str);
getchar();//ignore enter
for(;nextchar!='\n';) {
scanf("%c",&nextchar);
if(nextchar==' ')
space++;
else if('0'<=nextchar&&nextchar<='9')
number++;
else
others++;
}
printf("空格=%d,数字=%d,其他=%d\n",space,number,--others);
}
你这个逻辑就很不对好的么
而且你如果输入char类型的 就要考虑换行这个字符
少谈恋爱 且行且珍惜
你K定义的类型不对,应该是char 型,