-3

What is difference between Dynamic memory allocation and Static memory Allocation?

I don't understand this code:

int arrA[20];
int* arrB = new int [20];

What is the difference between those two lines? Why does Dynamic allocation have array size?

Constantin Groß
  • 10,719
  • 4
  • 24
  • 50

1 Answers1

0

In static memory allocation, memory is allocated during compile-time.

Whereas in dynamic memory allocation, memory is allocated during run-time.

The new keyword is used for dynamic memory allocation.

Deepesh Choudhary
  • 660
  • 1
  • 8
  • 17