J. Lily J. Lily - 1 month ago 15
C++ Question

output alignment issues in c++

I want to have these aligned but the strings are giving a problem. I have tried using left but it doesn't work here.

table preview

Answer Source

Let me guess, you're using tabs to separate the columns? The problem with this is that is has no justification (left or right), and it depends on the length of previously printed output since tabs are at fixed positions in the output, i.e. tabs are variable width.

If you want a fixed column width then you should use the std::setw manipulator.