I was doing tests to do parsers of date and I made this example based on a program that formats through sscanf()
with a constant string defined because I did not understand well where is the error:
#include <cstring>
#include <iostream>
int main()
{
int day, year;
char weekday[20], month[20], dtm[100];
printf
(
"\n\tDigite Dia Mes a ano em string"
"\n\tex.(Saturday March 25 1989): "
);
scanf("%s80[^\n]",&dtm);
sscanf(dtm, "%s %s %d %d", &weekday, &month, &day, &year);
printf("%s %d, %d = %s\n", month, day, year, weekday);
return 0;
}
/*
Input:
Saturday March 25 1989
Output:
'l 0, 0 = Saturday
where Output should be:
March 25 1989 Saturday * /