I\'ve got to read a date format (dd-mm-yyyy;) from a char* string using sscanf with this line of code:
sscanf(string, \"%[^-]-%[^-]-%[^;];\", day, month, yea
You need to pass the address of the int
variables:
int day, month, year;
sscanf(string, "%d-%d-%d;", &day, &month, &year);
sscanf()
returns the number of assignments made, recommend checking the return value before using day
, month
and year
:
if (3 == sscanf(string, "%d-%d-%d;", &day, &month, &year))
{
}