I have this code:
cout << std::setiosflags(std::ios::right);
cout << setw(3) << 1 << setw(3) << 2 << '\n'; // Output two values
cout << std::setiosflags(std::ios::left);
cout << setw(3) << 1 << setw(3) << 2 << '\n'; // Output two values
but the output doesnt come like i expected. instead of:
1 2
1 2
this comes out:
1 2
1 2
What is the problem? I set ‘std::ios::left’ but it makes no difference?
You have to clear the previous value in adjustfield before you can set a new one.
Try this: