首页 > 解决方案 > 将二进制文件读入 3d 浮点数组

问题描述

我想读取二进制文件并将数据存储到 3D 浮点数组中。我看过一些 1D 数组的示例,但不知道如何将其扩展为 3D。

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
    int N = 1024;
    // allocate 3d array
    float *** stmp = (float ***)malloc(N * sizeof(float**));
    for (int i = 0; i < N; i++) {
        stmp[i] = (float **)malloc(N * sizeof(float *));
        for (int j = 0; j < N; j++) {
            stmp[i][j] = (float *)malloc(N * sizeof(float));
        }
    }
    string path = "Velocity1_inertHIT.bin";
    ifstream infile;
    infile.open(path);


    return 0;
}

标签: c++

解决方案


推荐阅读