Array size based on function parameter?

Started by monkey0506, Sun 03/07/2005 01:52:56

Previous topic - Next topic

monkey0506

For some unknown reason I want to create an array based on the value of a function parameter.  I tried:

void Func(readonly int test) {
  int array[test];
  }

But there was a "parse error at 'readonly'".  So I tried this:

void Func(int test) {
  readonly int var = test;
  int array[var];
  }

But then it said "array size must be constant value".  So I figured, perhaps my readonly variable isn't being read as "readonly".  So I tried:

var = 5;

And it told me that "variable 'var' is readonly".  So, I have a constant value, but I can't use it as the size of an array.  Is there any way to base an array's size on the value of a function parameter?

Kweepa

Still waiting for Purity of the Surf II

monkey0506

Steve, you are a duck. :D

But seriously, there's really no way to do this?Ã,  What crap...

You can do it in real game creation systems.*
Spoiler
[/size]
*Just a joke.Ã,  I think this should be implemented in AGS, because it's nice to be able to create an array with a different size at different times...
[close]
[/color]
How the #*$@ did this happen?

SMF spam blocked by CleanTalk