#include <myhead.h>
int main(int argc, const char *argv[])
{
if(argc!=3)
{
printf("外部参数参数\n");
return -1;
}
FILE *fp1 = fopen("./1.txt","r");
if(NULL==fp1)
{
perror("fp1");
return -1;
}
FILE *fp2 = fopen("./2.txt","w");
if(NULL==fp2)
{
perror("fp2");
return -1;
}
while(1)
{
char buff = fgetc(fp1);
if(buff==EOF)
{
break;
}
fputc(buff,fp2);//放入文件2中
}
fclose(fp1);
fclose(fp2);
printf("拷贝成功\n");
return 0;
}
https://note.youdao.com/ynoteshare/index.html?id=46719ae93a4a8ad2b864099c37f15024&type=note&_time=1724150215053?auto
#include <myhead.h>
int main(int argc, const char *argv[])
{
if(argc!=3)
{
printf("外部参数参数\n");
return -1;
}
FILE *fp1 = fopen("./1.txt","r");
if(NULL==fp1)
{
perror("fp1");
return -1;
}
FILE *fp2 = fopen("./2.txt","w");
if(NULL==fp2)
{
perror("fp2");
return -1;
}
char buff[200];
fgets(buff,sizeof(*fp1),fp1);
fputs(buff,fp2);//放入文件2中
fclose(fp1);
fclose(fp2);
printf("拷贝成功\n");
return 0;
}