<span style="font-family:Microsoft YaHei;font-size:14px;">#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
FILE * fp;
FILE * fd;
char buf[1024];
fp=fopen("data1.txt","r");
if(fp==NULL)
{
perror("open file");
exit(0);
}
fd=fopen("data2.txt","w");
if(fd==NULL)
{
perror("open file");
exit(0);
}
while(fgets(buf,sizeof(buf),fp)!=NULL)
{
fputs(buf,fd);
printf("%s", buf);
}
fclose(fd);
fclose(fp);
return 0;
}</span>
C语言逐行读取文件内容,写入另外一个文件
最新推荐文章于 2025-04-11 09:59:59 发布