这样会多读一个字符
int main()
{
FILE * fp;
char num;
if((fp = fopen("表达式求值.txt", "r")) == NULL)
{
printf("文件打开失败!");
exit(0);
}
while(!feof(fp))
{
fscanf(fp, "%c", &num);
printf("%c", num);
}
return 0;
}
这样就不会多读
int main()
{
FILE * fp;
char num;
if((fp = fopen("表达式求值.txt", "r")) == NULL)
{
printf("文件打开失败!");
exit(0);
}
while(1)
{
fscanf(fp, "%c", &num);
printf("%c", num);
if(feof(fp)) break;
}
return 0;
}