allocating memory for a large 2-D array
hi,
i am writing a program in C which histograms data into a 2-D array. so i would like to work with a 4096x4096 array of type int which on my machine is 4-bytes (i'm running linux on a pentium II). after debugging, i've found that upon runtime, even the declaration:
int Array[4096][4096];
causes a "segmentation fault". the maximum value is:
int Array[1447][1447];
why the number 1447 i have no idea. i have searched this forum for help and found a suggestion using the function "malloc" but i'm not sure how to use this. could someone explain how i might override this limit and use a 4k x 4k array?
Thank you for any help you might be able to give.
-R.G.
thanks but still need help
thanks for your help. so in order to use the heap instead of the stack, i must use the function "malloc"? i'm not experienced with this and my C book does not go into enough detail. could you give me an example so that i may make the array as large as i require?
thanks so much for your time.
-R.G.