Unlike the malloc , I have never seen a if statement for checking whether the array has got enough space. So is it guranteed that the arrays always get enough space even though they are allocated in the stack? And what to do in case otherwise?
No guarantee at all.
There's no way to verify whether the stack allocation was successful or not. The C standard doesn't mandate any limits (min or max).
So you should check with your operating system which typically allocates a fixed size stack. For example, on my Ubuntu system, the stack size is 1MB. So it depends on your operating system.
In fact, if you start to have doubts whether stack size is enough, you should go for dynamic allocation (malloc).
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