This is a code from one book that I am reading. My question is (as you will see bellow) why even when setw(2) is set on 2, I still get 201 21 18 when I pick every number to be 99 out of all 6?
I did it just for test, I though setw(2) would limit width of every number to 2 numbers, for example 99 would be max. What am I now getting?
#include <iostream>
#include <iomanip>
using namespace std;
main()
{
int t1, t2, t, m1, m2, m, s1, s2, s;
cout << "Ange de två tiderna på formen tt mm ss" << endl;
cin >> t1 >> m1 >> s1 >> t2 >> m2 >> s2;
s = s1+s2;
m = m1 + m2 + s/60;
t = t1 + t2 + m/60;
s = s % 60;
m = m % 60;
cout << "Totaltid:"
<< ' ' << setw(2) << setfill('0') << t
<< ' ' << setw(2) << setfill('0') << m
<< ' ' << setw(2) << setfill('0') << s << endl;
}