#include 寫二進制文件 寫二進制文件應該使用ofstream類,文件的打開模式壹定要是binary,如果傳入的不是binary,文件將以ASCII方式打開。 下面是示例代碼,用於寫入文件。 std::ofstreamfout("a.dat",std::ios::binary); intnNum=20; std::stringstr("Hello,world"); fout.write((char*)&nNum,sizeof(int)); fout.write(str.c_str(),sizeof(char)*(str.size())); fout.close(); 而寫文本文件則比較簡單,如下: std::ofstreamfout("b.dat"); intnNum=20; std::stringstr("Hello,world"); fout<
上一篇:SLC,MLC和TLC三者的區別下一篇:Pm1603錯誤