where the variable store,and which place in memory
Data /variables of c++
Hi @mkjha
Basically there are 4 memory segments…
1. Stack
2. Heap
3. Data
4. Text/code
Stack -> A bunch of memory allocated when ever we call a sub routine. It will be destroyed when the function returns to main context.
All the variables declared inside the routine will be allocated in stack and will be destroyed after function return.
Heap -> Its memory available for Dynamic allocation (Malloc,Calloc).Its persistent of function calls. The memory will be released only when a free() is called.Most of the memory leak issues will be related to the heap.
Data - > All the regular variables declared in the main context and “Static” variables will be allocated in this segment.
Code -> Your source code will be available in this segment
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.