Hi.
I was reading some articles about static and dynamic memory allocation and there is something I don`t understand.
As I read, in assembly is it possible to extend the space used on the stack by incrementing the stack pointer. So why in C every statically allocated variable must have its size explicitly defined when writing the program, and it cannot change during execution?
Let`s say, I need an array, but I don`t know its size from the beginning. In this case I have to declare a pointer, allocate memory for it on the heap with malloc() and as the array`s size grows, call realloc(). Why can`t I declare an array statically on the stack like int array[100] and if needed, change its size to 101 and push the next value on the stack?
I don`t have any experience in assembly, so please excuse me, if I said something stupid.
Thank you.