Split a string
#1

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!
Reply
#2

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)