SA-MP Forums Archive
[SOLVED]How to use sscanf using 'additionnal delimiter' format? - 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]How to use sscanf using 'additionnal delimiter' format? (/showthread.php?tid=118447)



[SOLVED]How to use sscanf using 'additionnal delimiter' format? - x-cutter - 03.01.2010

Hey,
First of all, I'd like to separate entered text in a command, but all the data wouldn't be separated by spaces, but by '/' (birthdate) so I would type /birthdate dd/mm/yyyy (replace d, m and y by numbers) and I'd like to separate dd from mm and yyyy, etc. I've heard sscanf could do this, but only one problem, I don't know how!

Quote:
pX - An additional delimiter where X is another character.
Quote:
p<delimiter> Splitter The next character is used as a string delimiter, example:
"p|iii"
Will split this string into three integers:

1|2|3
Note that on things other than strings space is still used as well.
How to use this format?


Re: How to use sscanf using 'additionnal delimiter' format? - woot - 03.01.2010

pawn Код:
new d,m,y;
sscanf(input, "p/iii", d,m,y);
pYear[playerid] = y;
pMonth[playerid] = m;
pDay[playerid] = d;
In this case, "input" is the date (as string obv). This would split 11/1/1970 to d = 11, m = 1, y = 1970


Re: How to use sscanf using 'additionnal delimiter' format? - x-cutter - 03.01.2010

Quote:
Originally Posted by //exora
pawn Код:
new d,m,y;
sscanf(input, "p/iii", d,m,y);
pYear[playerid] = y;
pMonth[playerid] = m;
pDay[playerid] = d;
In this case, "input" is the date (as string obv). This would split 11/1/1970 to d = 11, m = 1, y = 1970
Okay, I see. I wasn't sure if I was doing the good thing.
Thanks!