I'm attempting to do some basic dynamic memory allocation and I've run into a problem I cannot seem to get around. First, if I try the following bit of code:
int x,y;
cin >> x;
cin >> y;
int arr [x][y];
I get the following compiler error:
"Constant expression required in function foo()"
In trying to skirt the above issue, I tried to code it this way:
int x,y;
cin >> x;
cin >> y;
int ** x1;
x1 = new int [x][y];
I get the same error as above plus:
"Cannot convert int(*)[1] to int **."
Am I coding this incorrectly?