I do not understand the logic in the following expression, although it works fine:
cout << left << setw(6) << "hello" << "there." ;
The previous code correctly outputs what I expect: hello there.
My logic is:
cout << "hello" << left << setw(6) << "there.";
But he outputs something unexpected: hellothere.My expectation is that the first character “t” “there” is in the 7th column on the output area, which is after the width of the columns 6. In other words, my concept is that “ left setw (n) "should mean" n columns (spaces) from the first in the output area ", like some data forms with numbered columns for easy data retrieval.
Could you explain?
source
share