日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

C++:读写二进制文件到double数组,根据二进制数据量进行读取

發布時間:2025/4/5 c/c++ 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C++:读写二进制文件到double数组,根据二进制数据量进行读取 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

代碼和數據在git

#include <math.h> #include <fstream> #include <iostream>#include <fstream> #include <iostream> #include <sstream> #include <string>using namespace std;//int readBinFile(std::string& filename, void*& bufPtr, int& pointNum, int pointDim)int main() {// open the file:std::streampos fileSize; //實例化fpos用于表示窄向流中的位置。std::ifstream file("cloud.bin", std::ios::binary);cout<<"file="<<!file<<endl;if (!file) {cout<<"!file"<<endl;return false;}// get its size://把文件的讀指針結尾位置向后移前個字節file.seekg(0, std::ios::end);fileSize = file.tellg();//把文件的寫指針從文件開頭向后移 0 個字節file.seekg(0, std::ios::beg);cout<<fileSize<<endl;int length=fileSize;double* f2 = new double[length];std::ifstream ifs("cloud.bin", std::ios::binary | std::ios::in);ifs.read((char*)f2, sizeof(double) * length);ifs.close();cout<<f2<<endl;/***for (int i = 0; i < length; i++){std::cout<<f2[i]<<std::endl;}***/return 0;}// read the data:

總結

以上是生活随笔為你收集整理的C++:读写二进制文件到double数组,根据二进制数据量进行读取的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。