[Solved] How to show double 00 like 00:00:59 in C++? [closed]


A simple way using std::setw and std::setfill is this:

int hour = 0;
int minute = 0;
int second = 59;

std::cout << std::setw(2) << std::setfill('0') << hour << ":";
std::cout << std::setw(2) << std::setfill('0') << minute << ":";
std::cout << std::setw(2) << std::setfill('0') << second << endl;

It will print:

00:00:59

0

solved How to show double 00 like 00:00:59 in C++? [closed]