[SOLVED]How to use sscanf using 'additionnal delimiter' format?
#1

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

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
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)