sscanf noob question - 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: sscanf noob question (
/showthread.php?tid=272557)
sscanf noob question -
TheArcher - 28.07.2011
Guys can you explain better with an exemple if its possible what does p for exemple
new line[24];
sscanf(line, "p<|>");
What does p and what is that value inside " | "
Re: sscanf noob question -
Gh0sT_ - 28.07.2011
AFAIK this will "split" your "variables", for example:
new variable = 0, variable2 = 10, string[4] = "yes", string2[3] = "no";
sscanf(line, "p<|>dds[4]s[3]", variable, variable2, string, string2);
and this will return 0|10|yes|no
Re: sscanf noob question -
JaTochNietDan - 28.07.2011
Gh0sts explanation was 100% accurate, it was backwords. sscanf is for
unformatting strings, not
formatting them. Although he was correct that p<|> means that the delimiter for splitting the string up is the | character. So for example if I have a string that is the following:
pawn Код:
JaTochNietDan:26:12:passwordhash
Then I would use this in sscanf to split it into the specified varibles using the : delimiter:
pawn Код:
sscanf(string, "p<:>s[24]dds[50]", Username, integer, integer2, password_hash);
Does that make sense? See the sscanf documentation for more information, it is all clearly explained there.
Re: sscanf noob question -
TheArcher - 28.07.2011
Thank you all