In C, I would have done it using realloc.
realloc
In C++, one would normally consider using the STL vector class.
vector
But how do I properly res
By doing what vector and realloc do internaly: make a new, bigger array, copy the content of the old one, and destroy the old one.