Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

 

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:

 

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

 

it compiles fine.

 

Can someone tell me what I'm doing wrong?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...