Using sscanf to check if a string follows a format
#1

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

The sscanf code should be like:

PHP код:
"p</>ddd" 
Reply
#3

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.
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)