这个程序中'//'是输出'/'所以是查询'/'的个数,不是查询逗号的个数。
在C函数库中有个函数是strchr()查询指定的字符所在的位置。
#include <stdio.h>
#include <ctype.h>
int main(void)
{
File *fp;
char *chr;
if(fp=fopen("text","r")==0)//假设“text”是要调用的文件
{
printf("text can't open!");
return 1;
}
while(feof(fp))
{
chr=strchr(fp,',');
count++;
}
fclose(fp);
return 0;
}
温馨提示:答案为网友推荐,仅供参考