Hi there, I am very new to C++ and I want to create an array of variable length.
I tried this:
int corners; cout << "Please enter the number of corners: "; cin >> corners; int x[corners];
but it came up with errors:
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'x' : unknown size
After some research I found this as a solution:
int corners; cout << "Please enter the number of corners: "; cin >> corners; int * const x = (int*)_alloca(corners * sizeof(int));
Whilst this does work, I was hoping someone could explain exactly what it meant/was doing.
I am using Visual C++ Express 2008.
Thanks very much for any help! :)