c语言中 fgetc函数、fputc函数实现文件的复制

1、

#include <stdio.h>

int main(void)
{
    FILE *sfp;
    FILE *dfp;
    int ch;
    char sfilename[FILENAME_MAX];
    char dfilename[FILENAME_MAX];
    printf("Please input the sfilename: "); scanf("%s", sfilename);
    printf("Please input the dfilename: "); scanf("%s", dfilename);
    
    if((sfp = fopen(sfilename, "r")) == NULL)
        printf("aSource file open failed.
");
    else
    {
        if((dfp = fopen(dfilename, "w")) == NULL)
            printf("aDestination file open failed.
");
        else
        {
            while((ch = fgetc(sfp)) != EOF)
                fputc(ch, dfp);
            fclose(dfp);
        }
        fclose(sfp);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14873959.html