I'm trying to print time in hh:mm format but when the time is like 01:01 it prints as 1:1. Here's my code:
void output(int hour, int min, char ampm){
cout << setw(2) << setfill('0') << "The time is: " << hour << ":" << min << " ";
if(ampm == 'P'){
cout << "PM";
}
else if (ampm == 'A'){
cout << "AM";
}
}
As I understand it, this should work. I include iomanip. Can you see anything wrong with it?