一个文件的内容复制到另一个文件中.

int main()
{
    FILE *fp,*fp1;
    char ch[]={};
    if ((fp=fopen("/User/Apple/Desktop/text.1","r"))==NULL)
    {
        printf("cannot open file\n");
        return 0;
    }
    else
    {fp1=fopen("/User/Apple/Desktop/text.2", "w");
        while(!feof(fp))
        {
            fread(ch, 1,1,fp);
            fwrite(ch,1,1,fp1);
        }
        
        fclose(fp1);
        fclose(fp);
        
    }
    return 0;
}

 

posted @ 2014-09-26 09:28  汪伟  阅读(247)  评论(0编辑  收藏  举报