{printf("Cannotopenfile!\n");exit(0);}
if((f2=fopen("p2.c","w"))==NULL))
{printf("Cannotopenfil - 高级语言程序设计(一)(00342) - 专业知识收录平台">
{printf("Cannotopenfile!\n");exit(0);}
if((f2=fopen("p2.c","w"))==NULL))
{printf("Cannotopenfil - 高级语言程序设计(一)(00342) - 专业知识收录平台">
阅读下列程序,写出程序的主要功能。
#include
#include
voidmain()
{FILE*fl,*f2;
intk;
if((fl=fopen("p1.c","r"))==NULL)
{printf("Cannotopenfile!\n");exit(0);}
if((f2=fopen("p2.c","w"))==NULL))
{printf("Cannotopenfile!\n");exit(0);}
for(k=1;k<=1000;k++)
{if(feof(f1))break;
fputc(fgetc(f1),f2);/*由p1.c读出字符后写入到p2.c中*/
}
fclose(f1);
fclose(f2);
}
主要功能:文件复制,将p1.C复制给p2.C
扫描二维码免费使用微信小程序搜题/刷题/查看解析。
版权声明:本文由翰林刷题小程序授权发布,如需转载请注明出处。