把数组整个存到文件中(包含读写文件)

C++读写文件:

头文件 fstream.h

读:ifstream  -> open -> seekg -> read -> close

写:ofstream -> open -> seekp -> write  -> close

 参数:ios::binary 等等 seekg、seekp定位

C读写

FILE* :  fopen -> fread -> fwrite -> fclose

 

数组存到文件:

file.write((char*)QuaryTable,table_size * sizeof(int ));

读:

if( table_size != fread(p_quary_table,4,table_size,fp) )

 

* fread 的返回值,判断第三个参数,读的个数。

 

posted on 2017-02-09 18:25  遥远飞行  阅读(884)  评论(0编辑  收藏  举报

导航