一、保存二进制

#include <iostream>
#include <fstream>

int main(){
    float* output = new float[100]();
    ofstream fout("test.bin", ios::binary);
    fout.write((char *)(&output[0]), sizeof(float)); 
    fout.close();
    return 0;
}

二、读取二进制

void Read()
{
    string str = "test.bin";
    float* freadbufs = new float[100];
    std::ifstream ifs(str, std::ios::binary);
    ifs.read((char*)freadbufs , sizeof(float) * 100);
    ifs.close();
    //delete freadbufs;
}

 

相关文章:

  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2022-02-09
  • 2021-11-16
  • 2021-10-01
  • 2022-12-23
  • 2021-06-08
猜你喜欢
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案