Adding new values ​​to an array in which it is unknown how many entries

There is an array, it can be any entries and very often 0 or 1. And you need to add another record to what is. Now I add, but one record is added and the next entry simply rubs the previous one and becomes in its place.
How can I add, not knowing the key?


Answer 1, Authority 100%

look for something similar to C++ library “Vector”, where you create an object

vector<typedef> name;
/*    */
name.push_back(smth);
/*       ,    []*/