So I've always been told you should use dynamic memory when you don't know the size of the array at compilation time. For example, the user needs to input the size of the array.
int n;
cin >> n;
int array[n];
for(int ii = 0; ii < n; ii++)
{
array[ii] = ii;
}
for(int ii = 0; ii < n; ii++)
{
cout << array[ii] << endl;
}
However this works fine for me, I've always thought I would need to use a pointer and the new operator. Is dynamic memory then only for when you want to change size of the array, free up space, or having the ability to control when to release the memory? Thanks.