I am trying to initialize all columns and rows of array of large size to 0, without using pointers in C. But sometimes it is getting a crash and sometimes it shows an error message about 'not enough memory'. And I don't want to use pointers in my application.
I have a local variable (inside a function) defined like this:
double myArray[50][785190]={0};
I tried the code above but it's not working.
double myArray[50][785190] = { 0 };not working. Is this at file scope or a local variable? You're allocating around 320 MiB; that's too big to fit on most stacks.staticfor file scope or not for global scope. With pointers, you could use dynamic allocation withmalloc()et al. There are a number of duplicates for this problem — creating a big array that crashes your program.