I have the following problem
int day;
int year;
char month[12][10];
printf("Enter date (e.g. January 1 2008)"\n");
scanf("s% d% d% \n",month, &day, &year);
Now if I enter date with a typo, say January 3 19ww,
"year" return a value of 19 and it ignor the typo ww.
On the other hand if I type year, say w990, it returns a garbage value
as (soemthing like -87293775) expected.
But if make the same type of typo for the day, it always return a garbage
value.
My question is why only 19ww return a value 19 and ignore the characters?
And how can I make 19ww return a garbage value so that I can catch it
though a check such as year > 0 || year < 2500 .



LinkBack URL
About LinkBacks


