#include "stdafx.h"
#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
FILE * pFile;
char buffer[] = { 'x' , 'y' , 'z' };
pFile = fopen ( "myfile.bin" , "wb" );//fopen打开失败返回NULL
if(pFile!=NULL)
{
fwrite (buffer , sizeof(buffer), 1 , pFile );
}
fclose (pFile);
return 0;
}
结果:向myfile.bin文件中写入三个字节xyz