Strings

5.5 - Padding 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;

Task

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.

Sample input

1/9/205

Sample output

0205-01-09
#include <iostream> #include <iomanip> #include <string> int main() { }