When an array is declared normally, is the memory allocated statically, dynamically or otherwise?

  allocation, c++, memory-management

For example if an integer array is declared:

int ar[12];

And here a vector of integers:

vector<int> ar;     //OR
vector<int> ar(12);

In either case, is memory allocated to the array at compile time or runtime? I know that vector class in C++ STL uses dynamic memory allocation but what about the ordinary array? Also:

int n;
cin >> n;
char ar[n];

If memory allocation is at compile time then how does this work? I can’t find anything scavenging the net.

Source: Windows Questions C++

LEAVE A COMMENT