SA-MP Forums Archive
[SOLVED] String tokenizer by delimeter - 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: [SOLVED] String tokenizer by delimeter (/showthread.php?tid=94023)



[SOLVED] String tokenizer by delimeter - joco96 - 27.08.2009

Hi!
I'd need a string tokenizer, which need a delimeter!
Please give me a function and an example.

Thanks!

Edit: It's solved!

sscanf is the answer =).


Re: String tokenizer by delimeter - dice7 - 27.08.2009

https://sampwiki.blast.hk/wiki/Sscanf_code


Re: String tokenizer by delimeter - joco96 - 27.08.2009

I tried this, but I didn't find a good example :/
Can't u show me one, please?


Re: String tokenizer by delimeter - joco96 - 28.08.2009

So anyone, please give me an example where can I set the delimeter (sscanf) :/


Re: String tokenizer by delimeter - Kyosaur - 28.08.2009

https://sampwiki.blast.hk/wiki/Fast_Commands

look at the heal/ban/givecash commands


Re: String tokenizer by delimeter - joco96 - 28.08.2009

will this work?
pawn Код:
new string[256], str1[128], str2[128], str3[128];
format(string, 256, "Test|Test2|Test3#");
if(sscanf(string, "s|s|s", str1, str2, str3) == 0) {
    printf("STR1:%s STR2:%s STR3:%s ", str1, str2, str3);
}



Re: String tokenizer by delimeter - dice7 - 28.08.2009

pawn Код:
if(sscanf(string, "p|sss", str1, str2, str3)
Quote:

will this work?

Well, try it !


Re: String tokenizer by delimeter - joco96 - 28.08.2009

Quote:
Originally Posted by dice7
pawn Код:
if(sscanf(string, "p|sss", str1, str2, str3)
Quote:

will this work?

Well, try it !
It works, so big thanks!
I neded it, cuz I wrote a tokenizer but it started to get so crazy :/.