将下面各语句组合成一条完整的程序
| 比较两个文件的内容,模拟考试系统中的自动评分。 (提问7) |
| #include "stdio.h" |
| main() |
| exit(0); |
| fp1=fopen("a1.txt","r"); |
| } |
| if(fp2==NULL) |
| int sum=0; |
| { |
| printf("file open error.\n"); |
| clrscr(); |
| char ch1,ch2; |
| if(fp1==NULL) |
| { |
| FILE *fp1,*fp2; |
| { |
| fp2=fopen("a2.txt","r"); |
| fclose(fp1); |
| } |
| fseek(fp1,0,0); |
| fclose(fp2); |
| while(!feof(fp1)) |
| { |
| fseek(fp2,0,0); |
| ch1=fgetc(fp1); |
| } |
| if(ch1==ch2) |
| printf("sum=%d",sum); |
| exit(0); |
| ch2=fgetc(fp2); |
| sum=sum+1; |
| printf("file open error.\n"); |
| } |
| getch(); |