#include #include //加入头文件,为exit提供原型main() { FILE *fp;char ch; if((fp=fopen("datafile.txt","r"))==NULL)//fp==null{ printf("file cannot be opened \n"); exit(1); } while (ch=fgetc(fp)&&ch!=EOF) //这里还需要改下fputc(ch,stdout); fclose(fp); }