/* Compile with `clang -std=c99 -Wall -o u2_date u2_date.c` */
/* Test with `../checkproject u2_date` *//* Compile with `clang -std=c99 -Wall -o u2_date u2_date.c` */
/* Test with `../checkproject u2_date` */Include C-libraries for input/output.
#include <stdio.h>
#include <stdlib.h>Read a date in the given format. You may always assume that the entered format is correct. Print it then in the format yyyy-mm-dd. The month and the day of your output must always consist of two digits (see example).
int main() {Define three variables, for the month, day, and year.
int mm, dd, yyyy;scanf will read from the terminal until the user presses
the enter key. We don’t check for any error conditions, as
the exercise description said we can assume the input will
always be well-formed.
scanf("%d/%d/%d", &mm, &dd, &yyyy);printf takes various format codes to print our variables
to the terminal. The format %0nd means to fix the output
width to n numbers, with 0 as the padding digit.
printf("%04d-%02d-%02d", yyyy, mm, dd);Return code 0 means everything OK, no error.
return 0;
}