函数原型:
size_t fwrite(
const void *buffer,
size_t size,
size_t count,
FILE *stream
);
参数列表:
buffer // 被写数据缓冲区的首地址,Pointer to data to be written
size //一次写入数据块的大小,Item size in bytes
count // 写如数据快的次数,Maximum number of items to be written
stream // 文件结构指针,Pointer to FILE structure
FILE* f = fopen("a.exe","wb");
int nStep=buffer.length()/4096 +1;
int nPie=4096;
int nCur=0;
int nLeft = buffer.length();
int nWrite = 0;
for (int i=0;i!=nStep;i++)
{
fwrite(buffer.c_str()+nPie*i,nPie,1,f);
}
fflush(f);
fclose(f);