Strings
In some case, we need to pad strings for outputs. For example we want leading zeros in our output number (0042
instead of 42
).
One way to do this is by using the std::setw(int w)
and the std::setfill(char c)
stream modifier which are included in the <iomanip>
header. For example:
// Prints out 0042
std::cout << std::setw(4) << std::setfill('0') << 42 << std::endl;
Your task is to create a program which converts the M/D/YY
format (no leading zeros) to the best format ISO 8601 YYYY-MM-DD
.
1/9/205
0205-01-09