   Max array size C++?
  I need a way to store a lots of numbers for a .3ds model loader. The problem is that it crashes when I try to increase the array. Like:Works:float X[2][5000];float Y[2][5000];float Z[2][5000];Instant crash:float X[10][5000];float Y[10][5000];float Z[10][5000];Have I reached some kind of a limit on the array size or what?   
  Probably; you might have reached the stack size limit.  You can increase the stack size in Visual C++, under Project Properties, Linker, System.   ;  Or allocate dynamically, assuming you have a 32-bit system, each array takes 5000 * 10 * 4 = 200.000 bytes. There's enough of that on the heap:float *X = new float[10 * 5000];X[(y * 5000) + x] = 5.0f;delete[] X;;Quote:Original post by _fastcallProbably; you might have reached the stack size limit.  You can increase the stack size in Visual C++, under Project Properties, Linker, System.What do I need to change? This is what I see: http://img541.imageshack.us/img541/3460/51844983.jpgQuote:Original post by DecriusOr allocate dynamically, assuming you have a 32-bit system, each array takes 5000 * 10 * 4 = 200.000 bytes. There's enough of that on the heap:float *X = new float[10 * 5000];X[(y * 5000) + x] = 5.0f;delete[] X;Does that still retain the [10][5000] look? I want to be able to access it like [object][vertex] (dont know how else to explain it)   ;  I wouldn't change the stack size at all, allocate the array with new[] instead - then you're bound by the available address space (~2GB on a 32-bit system), not the stack size.   ;Quote:Original post by TutenStainDoes that still retain the [10][5000] look? I want to be able to access it like [object][vertex] (dont know how else to explain it)No it doesn't. But practically you still do the same thing, basically it expands as:X[object][vertex] -> X[(object * max_vertices) + vertex] which equals *(X + (object * max_vertices) + vertex)So yes, you do need to remember max_vertices.;Quote:Original post by DecriusQuote:Original post by TutenStainDoes that still retain the [10][5000] look? I want to be able to access it like [object][vertex] (dont know how else to explain it)No it doesn't. But practically you still do the same thing, basically it expands as:X[object][vertex] -> X[(object * max_vertices) + vertex] which equals *(X + (object * max_vertices) + vertex)So yes, you do need to remember max_vertices.Make sense. But cant I do it this way: float (*x)[1000] = new float[1000][1000];   ;  Thats not how it works. This would be right:const int X = 1000;const int Y = 5000;float* Foo = new float[X*Y];And then access it like Decrius said.;Quote:Original post by mind in a boxThats not how it works. This would be right:const int X = 1000;const int Y = 5000;float* Foo = new float[X*Y];And then access it like Decrius said.Thanks, think I got it. Will turn back here if I have any questions.Thanks again!;Quote:Original post by TutenStainMake sense. But cant I do it this way: float (*x)[1000] = new float[1000][1000];Yes, that will work so long as you know all but the first dimension at compile time.int n = 10;float (*x)[1000] = new float[n][1000]; // worksfloat (*y)[n] = new float[1000][n]; // doesn't workYou may also be interested in boost::array and boost::multi_array.