當前位置:編程學習大全網 - 編程軟體 - 我用c4droid寫了壹段代碼,輸出為二進制文件後,有什麽方法可以從另壹

我用c4droid寫了壹段代碼,輸出為二進制文件後,有什麽方法可以從另壹

#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錯誤
  • copyright 2024編程學習大全網