A simple multidimensional C-style array gives a segmentation error: 11

const int L=10; std::complex<double> c_array[L][L][L][L][L][L] // 6 dimensions 

Space needed: 2 * 8 * 10 ^ 6 bytes

You should not use all the memory, right?

+6
source share
1 answer

For each process, there is a stack size limit. Therefore, if you really want to create this array locally (on the stack), the only solution is to increase the stack size limit for your program. How to change the stack size limit depends on your OS.

An alternative is to create this array on the heap. To do this, you need to use the "new" keyword as follows.

 std::complex<double> *c_array = new std::complex<double>[L][L][L][L][L][L]; 
+8
source

Source: https://habr.com/ru/post/948914/


All Articles