scanf("%s",str[i]);
str是字符串数组,str[i]才是字符串
修改如下,供参考:
#include<stdio.h>
#include<string.h>
int main()
{
int n,i=0,j,k,count;
char str[256][128];
scanf("%d",&n);
while(n--){
scanf("%s",str[i++]);
}
k=i;
for(i=0;i<k;i++){
count=0;
for(j=0;str[i][j]!='\0';j++){
if(str[i][j]>='0'&& str[i][j]<='9')
count++;
}
printf("%d\n",count);
}
return 0;
}