How its determined ? Does this depend on the compiler/Architecture/Host system ?
Example:
int array[0x8000000000000000];
For this line in a x86_64 bit system GCC outputs:
Error "size of array 'array' is too large".
An array can have a maximum of eight dimensions. You declared an array whose total size is greater than the maximum allowable size. The maximum allowable array size is 65,536 bytes (64K).
7 Answers. Save this answer. Show activity on this post. There is no fixed limit to the size of an array in C.
array size 10^7 to 10^8 declared globally(i.e. on heap) is possible…if u declare nething in the main or in ne fxn…it goes into the stack which has a smaller size hence ur 10^7 array did not work out…
Static arrays have their size or length determined when the array is created and/or allocated. For this reason, they may also be referred to as fixed-length arrays or fixed arrays. Array values may be specified when the array is defined, or the array size may be defined without specifying array contents.
By static array, I assume, you mean a fixed length array (statically allocated, like int array[SIZE]
, not dynamically allocated). Array size limit should depend on the scope of the array declared.
ulimit -a
to view and ulimit -s STACK_SIZE
to modify the stack size.static int array[SIZE]
), again, the array is stored in DATA or BSS section (based on whether the array is initialized or uninitialized respectively). The DATA and BSS section size are determined by underlying OS.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With