I am trying to fix a Segmentation Fault error that occurs when I am running a C++ program which is caused by a structure I am calling to be too large. I am looking for a way to use my pre-existing C++ structure and move it from the stack to the heap.
My code looks like this:
n = 300;
struct arrayStruct {
double arr[n][n];
};
int main(int argc, char *argv[]){
arrayStruct temperature;
// do a bunch of stuff including passing and receiving the arrayStruct within a few functions
return 0
}
I have tried using malloc and new but only seem to get errors that I have no idea how to fix them. I've tried within in the structure as well as the main file but can't seem to get it working.
Thanks in advance