0
請告訴我下面的代碼有什麼問題。執行後,將其表示以大小寫不敏感的方式計算字符在文件中出現的次數的錯誤
「的test.txt具有字母 'R' 的0實例」
`#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
FILE *fp;
char ch,cmp;
char f[100];
int count=0,tu1,tu2;
printf("Enter the file name\n");
scanf("%s",f);
fp=fopen(f,"r");
printf("Enter the character to be counted\n");
scanf("%c",&ch);
tu1=toupper((int)ch);
while((cmp=fgetc(fp))!=EOF)
{
tu2=toupper((int)cmp);
if(tu1==tu2)
{
count++;
}
}
fclose(fp);
printf("\nFile \'%s\' has %d instances of letter \'%c\'",f,count,ch);
return 0;
}`
您的意見是什麼?文件的內容是什麼?嘗試在'scanf('%c',&ch);'%c' –