关于fread和fwrite的问题,求高手指教
我想把C:\\aa.exe 这个文件复制成C:\\MFC\\bb.exe文件,但是程序运行结果后会复制不全,即只复制了一部分,所以bb.exe这个文件无法运行,请问我这样写哪里有问题,请高手修改。
#include <windows.h>
//#include <stdlib.h>
//#include <stdio.h>
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
FILE *fpSource;
FILE *fpDest;
char buf;
if (!(fpSource = fopen("C:\\aa.exe","r")))
{
return -1;
}
if (!(fpDest = fopen("C:\\MFC\\bb.exe","w")))
{
return -1;
}
while(fread(&buf,1,1,fpSource) != 0)
{
fwrite(&buf,1,1,fpDest);
}
fclose(fpSource);
fclose(fpDest);
return 0;
}