Using the <b>setf</b> member function for <b>cout</b> to format the alignment of output does not display correctly on the screen or in an output file. For example, using <b>cout.setf(ios::right)</b> to align text output to the right of the screen with the manipulator <b>setw(15)</b> will print out garbage characters instead of spaces when dumping all output into a file. Interestingly, if you put <b>cout.unsetf(ios::left)</b> right before you set the flag for right alignment, the garbage characters come before your output. If you don't manually unset the flag for left alignment, the garbage characters come after your output.
Created attachment 4207 [details] I encountered the bug while working on this program for my computer science class
*** This bug has been marked as a duplicate of 18861 ***