Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 891
Sebi2020 Avatar asked Sep 16 '25 07:09

Sebi2020


1 Answers

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.

like image 93
Some programmer dude Avatar answered Sep 17 '25 22:09

Some programmer dude