Hello i have a problem to solve...
I have to read an undefined sequence of numbers that terminates with the value -1
this has to be stored in an array(not a vector)
Is there any way to store unknown number of elements in an array?
The size of an array cannot be changed. However, you can create a larger array and copy the old contents over, which is exactly what a vector is doing.
That looks more or less okay, however you need to allocate the original array dynamically as well, so you can delete[] it later. And you only need to allocate a new array whenever the current capacity runs out (if you have more than 100 elements).