fgetc读空格问题
代码如下#include <stdio.h>
#include "stdlib.h"
int main()
{
FILE *fp;
int ch;
if((fp=fopen("temp.txt","r"))==NULL)
{
printf("file cnannot be opened\n");
exit(1);
}
while(ch=fgetc(fp)!=EOF)
printf("%d",ch);
fclose(fp);
return 1;
}
若在文件temp.txt中 输入1 11
测试结果是1111
问:为何
----------------解决方案--------------------------------------------------------
这样写貌似应该输出49324949才是
----------------解决方案--------------------------------------------------------
#include <stdio.h>
#include "stdlib.h"
int main()
{
FILE *fp;
int ch;
if((fp=fopen("temp.txt","r"))==NULL)
{
printf("file cnannot be opened\n");
exit(1);
}
while((ch=fgetc(fp))!=EOF) //注意这行,优先级!!
printf("%d",ch);
fclose(fp);
return 1;
}
[color=white]
----------------解决方案--------------------------------------------------------
知道哪错了
----------------解决方案--------------------------------------------------------
值得学习一下谢谢了哦
----------------解决方案--------------------------------------------------------