假定在当前盘当前目录下有2个文本文件,其名称和内容如下:
文件名a1.txta2.txt
内容121314#252627#
#include
#include
voidfc(FILE*fpl)
{charc;
while((c=fgetc(f01))!='#')putchar(C);/*输出非'#'字符*/
}
voidmain()
{FILE*fp;
if((fp=fopen("a1.txt","r"))==NULL)
{printf("Cannotopenfile!\n");exit(0);}
else{fc(fp);fclose(fp);}
if((fp=tbpen("a2.txt","r",))==NULL)
{printf("Cannotopenfile!\n");exit(0);}
else{fc(fp);fclose(fp);}
}
【正确答案】:输出结果:121314252627