简体   繁体   中英

How are arrays stored on the stack?

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM