c++ - 将二进制文件读入 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;
}
解决方案
推荐阅读
- shell - 如何在shell中传递特殊参数?
- php - 从数据库中生成的 url 中删除
- bluetooth-lowenergy - Band BLE 我没有通过 BluetoothGatt.getServices() 获得体温、血压服务
- c++ - 使用不带开关的大小写,请解释这段代码的输出
- php - 提交表单后 Sylius 丢失配置
- java - DataSource.getConection() 和 Connection.close() 是如何工作的?
- c# - 如何异步查询两个 IAsyncEnumerables
- r - 带有变化变量的 for 循环回归
- sql - 在同一个表中复制相同的值
- java - 向字符串添加数字验证