I am very surprised that the below code compiles fine. I always believed an array size must be a constant at compile time but it seems that I can take the user's input and use it as the array size. I am using GCC with the codeblocks IDE. Has anyone tried this and is there anything wrong with doing it?
int size;
cout<<"Enter array size : "<<endl;
cin>>size;
int arr[size];
// ...more action array with the array after which works fine