How can I print an string with padding in C++? Specifically what I want is:
cout << "something in one line (no prefix padding)"
cout << "something in another line (no prefix padding)"
set_padding(4)
cout << "something with padding"
cout << "something with padding"
set_padding(8)
cout << "something with padding"
cout << "something with padding"
That is, I’ll call cout many times and I don’t want to call setw(len) << "" all the time.
I suppose you could just make the pre-processor type it for you: