I may be missing the point of your question here, and if so I apologize. But, if you're not going to be deleting any items only adding them, why not simply assign a variable to the next empty slot? Every time you add a new value to the array, just increment the value to point to the next one.
In C++ a better solution is to use the standard library type std::list< type >
, which also allows the array to grow dynamically, e.g.:
#include <list>
std::list<int> arr;
for (int i = 0; i < 10; i++)
{
// add new value from 0 to 9 to next slot
arr.push_back(i);
}
// add arbitrary value to the next free slot
arr.push_back(22);