How to initialize large size of array to 0 in C -


this question has answer here:

i trying initialize columns , rows of array of large size 0, without using pointers in c. getting crash , shows error message 'not enough memory'. , don't want use pointers in application.

i have local variable (inside function) defined this:

 double myarray[50][785190]={0};  

i tried code above it's not working.

i thought this, @ least in c++, not sure if/when added c.

double myarray[50][785190]={{0}};  

but, said you're getting out of memory errors. declaring 300meg on stack not idea. move global variable (outside of functions) , no longer on stack. or declare static. in either case code not reentrant global or static array i'm assuming don't need such large array.

otherwise can clear well

double myarray[50][785190] memset(myarray, 0, sizeof(myarray)); 

though compiler generate same code under hood either style.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -