c语言文件初步入门文本拷贝
可判断文件是否打开
创建文件inflie.c
#include
#include
int main()
{FILE *infp,*outfp;char ch;if((infp=fopen("infile.c","r"))==NULL){printf("cannot open infile.c.\n");exit(0);
}
if((outfp=fopen("outfile.c","w"))==NULL)
{printf("cannot open outfile.c.\n");exit(0);
}
#if 0#else
while(1){ch=fgetc(infp);if(ch==EOF)break;fputc(ch,outfp);
}
#endif
fclose(infp);
fclose(outfp);
}
进行复制infile.c的内容进入outfile.c中
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
