SA-MP Forums Archive
String Inverse - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: String Inverse (/showthread.php?tid=176531)



String Inverse - i514x - 13.09.2010

i dont know how to explain it but i'll give an example

EG:

INPUT: "hello world!"
OUTPUT: "!dlrow olleh"

has anyone got a function that can do that to the string?


Re: String Inverse - Minokon - 13.09.2010

pawn Код:
stock StringInverse(const string[], dest[])
{
new len = strlen(string);
for(new i=0; i < len; i++)
    dest[i] = string[len-i];
return dest;
}
ok, i done that xd


Re: String Inverse - i514x - 13.09.2010

thanks to both of you

by the way, which of those two functions are better heh?


Re: String Inverse - [XST]O_x - 13.09.2010

pawn Код:
public OnGameModeInit()
{
    new string2[15]; // ******'s
    new string3[15]; // Minokon's
    StringReverse("Holy cow!",string2,15); //******'s
    print(string2);
    StringInverse("Holy cow!",string3); //Minokon's
    print(string3);
    return 1;
}
******'s printed "!woc yloH" while Minokon's printed null.


Re: String Inverse - RoBo - 13.09.2010

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
[pawn]
******'s printed "!woc yloH" while Minokon's printed null.
Because Minokon's put the end of string char at the beginning of the string!