If you've not lean't about using pointers for dynamic memory yet and about the heap memory then I suggest you do so!
Just make sure that you keep hold of the pointer value under array and make sure you delete it once you're finished with your data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
std::cin >> size;
int* array = newint[size];
//Do stuff with my data here
//This frees the memory back to the system
array = NULL;
This sets array to 0 instead of the position where the data used to be
(freed with delete), this is to prevent you accidentally accessing
unpredictable data sources.
@giblit.. I thought it was (typename)malloc(size) for the C compatible version... Anyways you have again forgot to mention that this must return memory back to the system when it's finished with free(ptr)