Through dynamic memory allocation, the following the code works perfectly.
int *ptr;
int size1;
cin >> size1;
ptr = new int[size1];
In static memory allocation, I get the following error: array bound is not an integer constant before ']' token
int size2;
cin >> size2;
int arr[size2];
Why is this so? Why can't we specify a variable size?
Variable length array is an extension supported by certain compilers and it not (yet) in the standard.