Why use an array if you don't know how many you're going to need? You should look into other containers, such as vector.