to "make" an array in C you need to allocate some memory, either statically or dynamically with malloc. In any case, the array will be mapped physically in your computer like in the RAM. So you need to have enough physical place to "make" it.
In your case, you want a char array of size: 1048576*16384*1024*sizeof(char) = 1048576*16384 MByte with char size is 1 byte.
That is just too much. The error you get is related to that. It tells you that the maximum size you can request is the max number for a signed integer. See: What is the maximum value for an int32?. which is way under what you want to allocate.
If you look at excel, the cells are all empty and no memory is reserved for them until they are filled.
Unless that array is a global variable, it would be allocated on the stack, whose size is limited (usually, 1MB for VC).
Large objects should be allocated on the heap with
malloc. However, such a huge (16TB approximately) object will never fit in the memory of any ordinary device. Chances are that you don't actually need all that memory at once. You should rewrite your algorithm.
User contributions licensed under CC BY-SA 3.0