void save_bin(std::vector<float> &data_vector, std::string name = "mnn.bin")
{
std::ofstream outFile(name, std::ios::out | std::ios::binary);
int size = int(data_vector.size());
outFile.write((char *)data_vector.data(), sizeof(float) * size);
outFile.close();
}
int write_bin_to_file(const char* file_path, char* buf, int size_buf )
{
FILE * fid = fopen(file_path ,"wb");
for(int i = 0 ; i < size_buf; i ++)
{
fwrite(&buf[i],sizeof(char),1,fid);
}
fclose(fid);
return 0;
}
标签:bin,std,int,float,char,vector,size
From: https://www.cnblogs.com/WEIWEI1095/p/17640138.html