0

Where the following variable and pointer are stored heap or stack?

Int a; Int *b=&a;

4th Apr 2020, 6:05 PM
Michel Ghaith
Michel Ghaith - avatar
1 Answer
+ 1
Both of them are stored on the stack. You only store on the heap when requesting memory from it, for example through calls to malloc() in C or new() in C++. In that case, you usually have a pointer sitting on the stack, which points to the allocated memory region on the heap.
4th Apr 2020, 6:10 PM
Shadow
Shadow - avatar