28.02.2010, 08:23
I need to return the first empty slot in array, So i wrote this function:
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?
pawn Code:
public GetFirstEmpty(array[])
{
new size = sizeof(array[]);
for(new a = 0; a < size; a++)
{
if(array[a] == 0)
{
return a;
}
}
return -1;
}
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?