short usually 2 bytes, So in your case the 3d array Matrix has size of
2 X 6 X 400 X 400 = 1920000 bytes = 1.83 Mega Bytes.
Don't you think it is much?
If your program is using this much of memory, ask yourself " Do I really need this much"?
And besides, why aren't you using vectors instead of arrays?
#include<iostream>
#include<vector>
int main()
{
using std::vector;
const short d1=4,d2=400,d3=400,init_val=0;
//Define it!!
vector<vector<vector<short> > > Matrix(d1,
vector<vector<short> >(d2,
vector<short>(d3,
init_val)));
//Use it!!
Matrix[0][25][14]=11;
std::cout<<Matrix[0][25][14];
}
I know the syntax is a bit discouraging. Thats why most people go with some wrapper classes like that of Boost's
multi_array
For time being cosider the following article from
Dr.Dobb's
At the worst case, follow Tux's suggestion and stick with arrays.