11.12.2012, 21:41
Quote:
|
If you return the string directly, you can't specify an array size, it's constrained to the size defined in the array declaration in the function!
pawn Код:
pawn Код:
pawn Код:
I used to think the direct return was good, until I ran into an array size problem with my file script. It used to do this: string = file_GetStr("key"); But that pre-defined the return string as 128 cells, no more, no less. So now it works like this: file_GetStr("key", string); Which also means I can do stuff like: pawn Код:
pawn Код:
|
"But that pre-defined the return string as 128 cells, no more, no less."
But actually, functions can return strings less than defined array size.
For example
pawn Код:
string_return()
{
new string[500];
format(string, 500, "Hello world!");
return string;
}
main()
{
new string[13];
format(string, 13, "%s", string_return());
print(string);
}

