SA-MP Forums Archive
Using sscanf to check if a string follows a 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)
+--- Thread: Using sscanf to check if a string follows a format (/showthread.php?tid=590303)



Using sscanf to check if a string follows a format - BKarner - 27.09.2015

This is the line I'm trying to do:

Код:
if(!(sscanf(dateofbirth, "d/d/d", given_day, given_month, given_year))) ToggleFlagOnMask(errorMask, MA_CHRCREATION_ERR_DOB_WRONG_FORMAT, true); printf("Format 1: %d || Format: %d/%d/%d", errorMask, given_day, given_month, given_year);
Trying to basically get this to get the day, month and year in that order (DD/MM/YYYY) but at the same time check that the "/" symbols are in place.

Any ideas?


AW: Using sscanf to check if a string follows a format - Kaliber - 27.09.2015

The sscanf code should be like:

PHP код:
"p</>ddd" 



Re: AW: Using sscanf to check if a string follows a format - BKarner - 27.09.2015

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
The sscanf code should be like:

PHP код:
"p</>ddd" 
Thanks! that's fixed the issue. Would you mind explaining what the p</> actually means?
+Rep.


Re: Using sscanf to check if a string follows a format - IstuntmanI - 27.09.2015

With p you can specify a delimiter (in this case /) between the following specifiers (ddd in this case), the delimiter should be between a < and a > .