首页 > 代码库 > c语言文件复制

c语言文件复制

#include<stdio.h>
#include<stdlib.h>

void main(void)
{
    // locate
    char infile[20], outfile[20];
    gets(infile);
    gets(outfile);

    // open
    FILE *in, *out;
    in = fopen(infile, "r");
    if(in == NULL)
        printf("error: without infile\n");
    else
        printf("infile has open.\n");
    out = fopen(outfile, "w");

    // operate
    while(!feof(in))
        fputc(fgetc(in), out);

    // close
    if(fclose(in) == 0 && fclose(out) == 0)
        printf("close successfully\n");
    else
        printf("fclose: error\n");
    return;
}

 关于文件的概念:

文件的签名,

文件的存储形式,

文件的操作方式。

c语言文件复制