template <typename T>
int save_bin_file(std::string file, int size, T *buffer)
{
std::ofstream ofs(file, std::ios::binary | std::ios::out);
if (ofs)
{
ofs.write((const char *)buffer, sizeof(T) * size);
ofs.close();
}
else
{
printf("open fail errno = %d reason = %s \n", errno, strerror(errno));
return -1;
}
return 0;
c++ 读写float二进制文件
最新推荐文章于 2024-04-02 14:05:12 发布