里找一个字符,输出找到的个数,程序如下: #include <stdio.h> int main() { char s[100]; char t; int i,n=0; printf("input one line string:\n"); gets(s); printf("input a char which you want to search:\n"); fflush(stdin); //为了读入一个字符,要先清除一次输入缓冲区 scanf("%c",&t); //读一字符 for (i=0;i<strlen(s);i++) if (s[i]==t) n++; //判断 printf("there are %d char %c in the string\n",n,t); //输出 return 0; }