Wednesday, 15 May 2013

Segmentation fault due to large 2D array in C++ structure -



Segmentation fault due to large 2D array in C++ structure -

this question has reply here:

segmentation fault on big array sizes 5 answers

i trying prepare segmentation fault error occurs when running c++ programme caused construction calling large. looking way utilize pre-existing c++ construction , move stack heap.

my code looks this:

n = 300; struct arraystruct { double arr[n][n]; }; int main(int argc, char *argv[]){ arraystruct temperature; // bunch of stuff including passing , receiving arraystruct within few functions homecoming 0 }

i have tried using malloc , new seem errors have no thought how prepare them. i've tried within in construction main file can't seem working.

thanks in advance

try utilize vector create 2d array:

#include <vector> struct arraystruct { arraystruct() : arr(n, std::vector<double>(n)) { } std::vector<std::vector<double>> arr; };

c++ multidimensional-array struct heap stack-overflow

No comments:

Post a Comment