随笔 - 51  文章 - 0  评论 - 0  阅读 - 5496

数据库——文件复制

#include <stdio.h>
int main()
{
FILE *fp;
FILE *from;
char ch;
char p[20]="hello";
fp = fopen("test.c","r+");
from =fopen("copy2.c","w+");
if((fp=fopen("test.c","r"))==NULL)
{
printf("Cannot open test.c strike any key exit!\n");
exit(1);
}
else
{
fwrite(p,1,5,fp);
}
if((from=fopen("copy2.c","w+"))==NULL)
{
printf("Cannot open copy2.c strike any key exit!\n");
exit(1);
}
else
{
fseek(fp,0,SEEK_SET);
ch=fgetc(fp);
while(ch!=EOF)
{
fputc(ch,from);
ch=fgetc(fp);
}
}
printf("\n");
fclose(from);
fclose(fp);
return 0;
}

posted on   慧茗子  阅读(9)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

点击右上角即可分享
微信分享提示