I am trying to create a very large 3D array. I am currently using a psuedo-3D array with a 1D array. Here is what I have so far:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <istream>
#include <string>
#include <vector>
#include <numeric>
using namespace std;
const int depth = 500;
const int height = 500;
const int width = 500;
int jimmy [height*width*depth];
int n,m,k;
int x = 2, y = 1, z = 2;
// m=x, n=y, k=z
int main ()
{
for (k=0; k < depth; k++)
for (n=0; n < height; n++)
for (m=0; m < width; m++)
{
jimmy[m + n * width + k * width * height] = (m+1)*(n+1)*(k+1);
}
system("pause");
return 0;
};
This is working fine so far. However, I would like to set the depth, height and width to 1000 or greater. When I make an array this big I get the following error:
Error 1 error C2148: total size of array must not exceed 0x7fffffff bytes
What would be the easiest way to build an array this large (1000x1000x1000) while avoiding this problem?