I need help figuring out why is this not working in C language.
My intention is to allocate statically two 2D array like this:
unsigned char raw_image2D[RAW_HEIGHT][RAW_WIDTH];
unsigned char raw_image2D_mirror[RAW_HEIGHT][RAW_WIDTH];
Where RAW_WIDTH and RAW_HEIGHT are defined as follows;
#define RAW_WIDTH 1600*3
#define RAW_HEIGHT 1200
Why is this not working, it compiles but at run time it breaks saying it is stack overflow?
Thank you
P.S. Why is this question so bad that you are giving a minuses?
NOTE : Solved by adding static in front of array declaration.
I will give points to that answer who suggested this solution, although others are possible but I need [][] annotation.
You have a stack overflow. For example on some system the stack size per process is set to 4 Mo.
4800 * 1200would be too much in that case (> 4 Mo).Use an array with static storage duration or better, use
mallocto allocate your array.