Posts: 3,324
Threads: 96
Joined: Sep 2013
1st off, you should be putting a string size
before it too.
2nd, you DON'T need the '&' on strings.
This works:
pawn Код:
#include <a_samp>
testfunc(string_length, string[]) {
strcat(string, "0123456789", string_length);
}
main() {
new bleh[15] = "bleh";
testfunc(15, bleh);
printf("bleh = %s", bleh);
}
Lastly, it doesn't look like you know what 'stock' means. Using the 'stock' keyword makes the definition optional to the compiler. If the compiler decides the function is never used it won't be defined. You should only use it in includes and such.
Posts: 579
Threads: 5
Joined: Oct 2015
PHP код:
// anywhere of script:
new foo[50], bar[60];
GetFooBar(foo, bar);
printf("foo: %s bar: %s", foo, bar); // << prints: "foo: I'm passed through reference. bar: Me too."
stock GetFooBar(foo[], bar[])
{
strcat(foo, "I'm passed through reference.", 50);
strcat(bar, "Me too.", 60);
return true;
}
You don't need '
&' symbol to pass arrays (strings) through reference.
Posts: 373
Threads: 59
Joined: Jun 2014
Reputation:
0
Thanks PawnHunter! Worked! Also i have to mention Crayder, i think that i misunderstood you.
+REP anyway :)