I have been asked to prove that one can set the array length in the program, and it does not need to be determined at compile time. I have following code:
#include<iostream>
using namespace std;
int main()
{
int x, myarray[x];
cout << "Enter the size of array" << endl;
cin >> x;
}
But when I compile, I get the following errors:
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'myarray' : unknown size
I'm not sure what the right way to approach it.