I'm writing a program for that takes dates as input using scanf. I
want to verify that the user is inputting a full 4 digits for the
year. How do I do this? I know that the return value on printf is the
number of printed characters; so if I could somehow get my year
variable to store the leading zeros, I could just run a check:
int dummy = 0;
dummy = printf("%d", year);
if (dummy != 4)
{
...do something...
}
want to verify that the user is inputting a full 4 digits for the
year. How do I do this? I know that the return value on printf is the
number of printed characters; so if I could somehow get my year
variable to store the leading zeros, I could just run a check:
int dummy = 0;
dummy = printf("%d", year);
if (dummy != 4)
{
...do something...
}
Comment