[cpp] #include <iostream> #include <crtdbg.h> using namespace std; FILE *fp; char SP_NAME[]="cq.dat"; int BLOCK_NUM=65536;//64*1024 int BLOCK_SIZE=512; #define biteNum 33554432//64*1024*512 void init() { int i,j; fp = fopen(SP_NAME,"w"); //文件寫入方法一 /*for(i=0;i<BLOCK_NUM;i++) { for(j=0;j<BLOCK_SIZE;j++) { fprintf(fp,"%c",'\0'); } } */ //文件寫入方法二 char *memory=(char*)malloc(biteNum);//<a href="http://baike.baidu.com/view/736228.htm">http://baike.baidu.com/view/736228.htm</a> memset(memory,0,biteNum); fwrite(memory,1,biteNum,fp);//<a href="http://baike.baidu.com/view/656700.htm">http://baike.baidu.com/view/656700.htm</a> fclose(fp); free(memory); } int main() { init(); return 0; }