If you want a static array(const number of items), use std::array
:
std::array<int,50> a;
If you want a dynamic array(non const number of array), use std::vector
:
std::vector<int> a(50);
in this case you can change the size of the vector any time you want by resizing
it:
a.resize(100);
or just by pushing new items:
a.push_back(5);
read more about std::vector
. It can serve you more than you can imagine.
P.S. the second code of your question is not valid (or at least it is not standard). However, you can do this instead:
int x;
cin>> x; //Input a number to initialise the array.
std::vector<int> array(x);