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

wchenfeng

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

公告

View Post

文件,在操作台上进行自主文件拷贝,并进行自主命名。

#include<stdio.h>
#include<stdlib.h>
int main()
{
	FILE *infp,*outfp;
	char ch;char a[128],b[128];
	printf("请输入本文件目录中存在的文件名加后缀:");
	gets(a);//infile.txt
	printf("请输入输出文件名加后缀:");
	gets(b);
	if((infp=fopen(a,"r"))==NULL)
	{
		printf("cannot open %s\n",a);
	exit(0);
}
if((outfp=fopen(b,"w"))==NULL)//outfile.txt
{
	printf("cannot open out %s \n",b);
	exit(0);
}
#if 0
 
#else 
while(1)
{
	ch=fgetc(infp);
	if(ch==EOF)
		break;
	fputc(ch,outfp);
}
#endif
fclose(infp);
fclose(outfp);
printf("复制成功\n");
}

 

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

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