Split a string - 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)
+--- Thread: Split a string (
/showthread.php?tid=337914)
Split a string -
Biesmen - 28.04.2012
How can I split a string using sscanf (or any other function)?
E.g:
pawn Код:
new string[64],
string2[50];
format(string, sizeof(string), "Hello my name is %s from SA-MP.com!", playername);
I'd like to split the string from character position 14 in string2.
This would be:
string will be: Hello my name is
string2 will be: Biesmen from SA-MP.com!
Re: Split a string -
Hiddos - 28.04.2012
I'm no fairy queen when it comes to strings, but you could try something with strmid:
pawn Код:
new string[64],
string2[50];
format(string, sizeof(string), "Hello my name is %s from SA-MP.com!", playername);
strmid(string2, string, 15, sizeof string); //15 instead of 14, so it doesn't copy the space before the name
strdel(string, 14, sizeof string);