سؤال

I know how arrays stored on the heap. But how are arrays stored on the stack? Is the complete array pushed to the stack?

هل كانت مفيدة؟

المحلول 2

Yes, the whole array is pushed on stack.

See the following answer on how variables are allocated on the stack:

https://stackoverflow.com/a/18479996/1814023

نصائح أخرى

Arrays are stored the same no matter where they are. It doesn't matter if they are declared as local variables, global variables, or allocated dynamically off the heap. The only thing that differs is where they are stored.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top