One of the thing I will never understand is why who is learning C++ is always tempted (or directed to) learn as it is C.
C++ support classes and abstract types and has a standard library whose specification is part of the language and that should be studied together with the language.
Give a look to
std::vector[
^].
All you need is a
std::vector<int> a;
and then, every time you have a value to insert in it, just call
a.push_back(your_value);
You can then know the size with
a.size()
and access the values as usual as
a[x]
.