sscanf()
, "%[]"
"%n"
.
// if (sscanf(datestr, "%d/%d/%d", &day, &month, &year) != 3) return NULL;
int n[3] = { 0 };
sscanf(datestr, "%*[0-9]%n/%*[0-9]%n/%*[0-9]%n", &n[0], &n[1], &n[2]);
if (n[0] != 2 || n[1] != 5 || n[2] != 10) return NULL;
// Good To Go
sscanf(datestr, "%d/%d/%d", &day, &month, &year);
if (!ValidDate(year, month, day)) return NULL;
, - . . 30 1712 .?
,
int ValidDate(int year, int month, int day) {
struct tm tm1 = { 0 };
tm1.tm_year = year - 1900;
tm1.tm_mon = month + 1;
tm1.tm_mday = day;
struct tm tm2 = tm1;
if (mktime(&tm1) == -1) return 0;
if (tm1.tm_year != tm2.tm_year) return 0;
if (tm1.tm_mon != tm2.tm_mon) return 0;
return tm1.tm_mday == tm2.tm_mday;
}