#include <stdio.h> #include <stdlib.h> #define N 100 int main(){ FILE *fp; char str[N+1]; if((fp=fopen("report", "rt")) == NULL){ fprintf(stderr, "Cannot open file!\n"); exit(1); } while(fgets(str, N, fp) != NULL){ printf("%s", str); } printf("\n"); if(ferror(fp)){ puts("Something wrong to read the file\n"); }else{ puts("Read the file successfully!\n"); } fclose(fp); return 0; }