Declaring an Array with a Const Parameter

Meanie

Newcomer
Joined
Jan 4, 2003
Messages
23
I want to create an array in a function using an integer that I pass. The compiler requires that I use a contant value, so I am trying to use the following:

Code:
void WriteData(const int count)
{
	int levelArray[count];
}

What happens is the compiler gives me an error and tells me that count isnt a constant.

However, when I try this:

Code:
void WriteData()
{
	const int count = 5;
	int levelArray[count];
}

it compiles fine.

Can someone tell me what I'm doing wrong?
 
Back
Top