阅读背景:

计算用户输入整数与c程序中的文本文件匹配

来源:互联网 
#include <stdio.h>
#include <stdlib.h>

int main()
{
FILE *file;
int word;
int num,num2;
int numcount1=0,numcount2=0;

printf("Please enter a keys: ");
if (scanf("%d %d", &num, &num2)==2 ){
} else {
    printf("Error:Must two integers");
}

file=fopen("data.txt","r");

while ((word=fgetc(file))!=EOF){
    fprintf(stdout, "%c",word);
    if (word == num)  numcount1++;
    if (word == num2)  numcount2++;
}
printf("'%d' is found %d times in the txt file\n",num,numcount1);
printf("'%d' is found %d times in the txt file\n",num2,numcount2);
fclose(file);
return 0;
}
#include <stdio.h>
#include <stdlib.h>

int mai



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: