本段代码实现了将一个文件内容复制到另外一个文件中的功能

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    FILE *fp1,*fp2;
    if((fp1=fopen("file1.c","r"))==NULL)
    {
        printf("cannot open file1\n");
        exit(0);
    }
    if((fp2=fopen("file2.c","w"))==NULL)
    {
        printf("cannot open file2\n");
        exit(0);
    }
    while(!feof(fp1))
        putchar(getc(fp1));
    rewind(fp1);/*将文件1的指针重新定位到文件的开头处*/
    while(!feof(fp1))
        putc(getc(fp1),fp2);
    fclose(fp1);
    fclose(fp2);
    printf("copy compony\n");
    return 0;
}




阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6