I have searched for help on this on the internet, but I'm not quite sure why I can't use a variable as the array size in this one. I read that C99 compilers can accept this and this is how my C++ textbook says to do this, so I'm having trouble locating the problem. I am running Visual C++ 2005 Express Edition, but I am new to this and don't know what compiler this Visual C++ has so there is a chance the compiler isn't a C99. Is there any other way to get this code to compile with a variable as the array size? The line with the error "expected constant expression" starts off with the declaration and initialization:

Code:

int studentScores[numOfScores]={0};

I even tried an initialization array instead of this at one point, but it just caused more errors with the same "expected constant expression" as the first error. Since it isn't that long, I've posted the complete code. If any more information or clarification is needed, don't hesitate to ask and thank you in advance for the help.

VC2005 is a C/C++ compiler, but not C99 compliant. Few are. Dev-C++ will accept your method (it uses MinGW). I would advise you, at least for a while, to use dynamic allocation or move to C++ and use a container such as those provided in the STL.