Are arrays reference-type or value-type in PAWN?
#1

The reason for this question is that if the example code will alter the array from the argument or do I have to explicitly use the '&' reference operator?

pawn Code:
stock SomeFunction(somearray[], len = sizeof(somearray))
{
    somearray[0] = EOS;
    strcat(somearray, "Modified Array", len);
}

new anotherarray[16] = {'A', 'R', 'R', 'A', 'Y'}
SomeFunction(anotherarray, 16);
//Well now will the value of the array becomes "Modified Array" or stays "Array"?
// If it doesn't I have to reference it right?
Reply
#2

You don't need the &, it should work as long as the parameter isn't a constant.
Reply
#3

Quote:
Originally Posted by king_hual
View Post
You don't need the &, it should work as long as the parameter isn't a constant.
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)