[QUESTION] Is it possible to return a function an array?
#1

well, the tite pretty much says it. I am working here on a funcion and it'd be best if I not use any values in the include, and i'd like to return an array. Is it possibe? and if yes - how? Else, I'll just make a new array in the include and assing what is needed to it
Reply
#2

You mean something like this?
pawn Код:
new Test[4];

stock TestFunc()
{
for(new i=0;i<sizeof(Test);i++)
Test[i]=random(1337)+1;
return Test;
}

Reply
#3

exactly. But I wonder how could be handled with the function? I mean it returnas an array but how to assign an new array to the returning array ?

pawn Код:
new array1 = FunctionReturningArray();
Reply
#4

Both the arrays have to be the same size.

pawn Код:
new array[5];

array = ReturnArray();

ReturnArray()
{
  new array2[5];
  return array2;
}
Reply
#5

ok. what about muti-dimensional arrays? is that possible too if the arrays have same size?

f.e.
new array[8][8];
Reply
#6

yes, why not?
Reply
#7

ok, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)