Use std::vector for this. For example:
std::vector<int> values;
values.resize(n);
The memory will be allocated on the heap, but this holds only a small performance drawback. Furthermore, it is wise not to allocate large datablocks on the stack, as it is rather limited in size.