Possible Duplicate:
Variable length arrays in C++?
I am trying to form an array whose size is governed by another variable fed in by the user. I am a beginner in C++ coding and I am using the visual studio 2008 professional compiler. This is the code where the compiler shows the error:
double kplus2(double a, double ks, double kr)
{
int n = (ks-1)*100000;
double x[n];
The error is
Error 2 error C2057: expected constant expression
Error 3 error C2466: cannot allocate an array of constant size 0
Error 4 error C2133: 'x' : unknown size