Global memory management in C++ : Stack or Heap?

C++Server Side ProgrammingProgramming

Stack and heap are used to store variables during the execution of the program and it also get destroyed.

Global data structures or global variables are not consumed by stack or heap. They basically allocated in a fixed memory block, which remains unchanged.

int a[10]; // located in a fixed memory block
int main() {
   int main() {
      float *ptr = (int *)malloc(sizeof(float)10.0)); //use heap.
   }
}
raja
Published on 03-Apr-2019 08:46:48
Advertisements