hi trying to load a 3d array from a file array widthlength3

hi

trying to load a 3d array from a file       ....... array [width][length][3] - as it loads - it crashes

someone said I need a pointer- please show how c++

Solution

#include <vector>

using std::vector;

#define HEIGHT 5

#define WIDTH 3

#define DEPTH 7

int main() {

vector<vector<vector<double> > > array3D;

// Set up sizes. (HEIGHT x WIDTH)

array3D.resize(HEIGHT);

for (int i = 0; i < HEIGHT; ++i) {

    array3D[i].resize(WIDTH);

    for (int j = 0; j < WIDTH; ++j)

      array3D[i][j].resize(DEPTH);

}

// Put some values in

array3D[1][2][5] = 6.0;

array3D[3][1][4] = 5.5;

return 0;

}

hi trying to load a 3d array from a file ....... array [width][length][3] - as it loads - it crashes someone said I need a pointer- please show how c++Solution#

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site