Let's say I want to create an integer array whose size will be determined at runtime. The suggested way is
int n;
cin >> n;
int* array = new array[n];
But what's wrong if I do it this way? I mean it's got the advantages of static allocation, and the size is still dynamic!
int n;
cin >> n;
int array[n];
I couldn't find any straight forward answer. On a side note, is there any use at all of malloc()
in CPP?