JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

C++ save vector or float to bin

发布时间 2023-08-18 11:58:39作者: WEIWEI1095
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;
} 
    本栏目推荐文章
  • 1.12_redis 的存取在最后 晚上_浙江本地环境的header不能用线上的_header中host和refer分别代表什么意思?_模型的save()参数是数组怎么理解?
  • cdn引入vue后报错无法识路径 Uncaught TypeError: Failed to resolve module specifier "vue". Relative references must start with either "/", "./", or "../".
  • vector的学习
  • 通用mapper tk.mybatis A and (B OR C)
  • android编译kanzi 问题 (1) Caused by: java.io.FileNotFoundException: Error: Could not find or access Kanzi's Android libraries directory: C:\XXXXXXX
  • java上传图片or头像
  • nuxt构建失败:if (codePoint 》= 0x3_00 && codePoint (= 0x3_6F) { SyntaxError: Invalid or unexpected token
  • [protobuf] ProtoBufEditor 解析bin文件和json文件
  • No appropriate protocol (protocol is disabled or cipher suites are inappropriate)衫德钱包http请求时候
  • Name or service not known 完美解决
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们