c语言 13-13

1、

#include <stdio.h>

int main(void)
{
    int ch;
    FILE *sfp;
    FILE *dfp;
    char sfile[FILENAME_MAX];
    char dfile[FILENAME_MAX];
    printf("source file name: "); scanf("%s", sfile);
    printf("destinatiom file name: "); scanf("%s", dfile);
    
    if((sfp = fopen(sfile, "rb")) == NULL)
        printf("aSfile open failed.
");
    else
    {
        if((dfp = fopen(dfile, "wb")) == NULL)
            printf("aDfile open failed.
");
        else
        {
            int n;
            while((n = fread(&ch, sizeof(int), 1, sfp)) > 0)
            {
                fwrite(&ch, sizeof(int), 1, dfp);  
            }
             fclose(dfp);  
        }
        fclose(sfp);
    } 
}
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14875636.html