• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

wchenfeng

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

c语言文件初步入门文本拷贝

可判断文件是否打开

创建文件inflie.c

#include<stdio.h>
#include<stdlib.h>
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中

posted on 2022-04-12 20:03  王陈锋  阅读(41)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3