您的位置:首页 > 其它

任何文件复制的函数

2014-10-23 09:28 183 查看
FILE *fpa,*fpb;

char buf[5];

if ((fpa = fopen("..\\","rb"))==NULL)

return 0;

if ((fpb = fopen("..\\","wb"))==NULL)

return 0;

memset(buf,0,5*sizeof(char));

fseek(fpa,0,SEEK_SET);

fseek(fpb,0,SEEK_SET);

while (1)

{

if (fread(buf,1,1,fpa)!=1)

{

if (!feof(fpa))

{

cout<<"file read error!"<<endl;

}

else

{

break;

}

}

if ((fwrite(buf,1,1,fpb)) !=1)

{

cout<<"file write error!"<<endl;

}

}

fclose(fpa);

fclose(fpb);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: