Help with arrays
#1

I need to return the first empty slot in array, So i wrote this function:

pawn Code:
public GetFirstEmpty(array[])
{
    new size = sizeof(array[]);
    for(new a = 0; a < size; a++)
    {
      if(array[a] == 0)
      {
        return a;
      }
    }
    return -1;
}
Problem is, When the array is empty it returns 0 (Which is correct)
But when i put something in slot 0, It returns -1.
Halp?

I think its the if(array[a] == 0)
But what should i replace the 0 with?
Or does anyone else have a working function?
Reply


Messages In This Thread
Help with arrays - by Gozerr - 28.02.2010, 08:23
Re: Help with arrays - by Gozerr - 28.02.2010, 09:06
Re: Help with arrays - by adsy - 28.02.2010, 10:36
Re: Help with arrays - by Gozerr - 28.02.2010, 13:07

Forum Jump:


Users browsing this thread: 1 Guest(s)