0
I was doing some tests to do parsers date and made this example based on a program that formats through the sscanf()
with a string constant defined but not understood 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 */
Is that a question or an answer?
– Danilo Favato
is a question wanted to understand which error is that I forgot to describe trying to format the code here but I could not there someone formatted it..
– dark777
actually output ai should be: March 25 1989 Saturday
– dark777
Edit your question to be clear to everyone, it should attract more people to answer.
– Danilo Favato
This code does not even compile. At least in a good compiler.
– Maniero
C or C++? I believe you made a slight mistake in marking the language
– Jefferson Quesado
@dark777 The answer solved your question? Do you think you can accept it? See [tour] if you don’t know how to do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.
– Maniero
the answer that helped me has already been voted...
– dark777