Title: Visual C++ Formatted Output
Course: CPS 120: Introduction to Computer Science ~ Master (Aug/2015) OLD > Section: Learning Units

- By default:
  - A string takes as many characters as needed to show.
  - A whole number (integer) is shown with no decimal point.
  - A real number is rounded to up to four decimal places.

- Console output may be formatted into columns, and numbers may be formatted with the following cout manipulators and statements:

Manipulator / Statement | Description
endl | Output a newline character.
setw(<length>) | Show the next output expression in a column <length> characters wide.  This setting is in effect until that expression or an endl is processed.
left | If any following output expression is narrower than a specified column width, left-justify it in the column.  This setting is in effect until the next right manipulator is processed.
right | If any following output expression is narrower than a specified column width, right-justify it in the column.  This setting is in effect until the next left manipulator is processed.  right is the default alignment.
setfill(<char>) | If any following output expression is narrower than a specified column width, fill that column with <char>.  This setting is in effect until the next setfill is processed.
fixed | Round any numbers that follow to six decimal places.  This setting is in effect until the next number formatting manipulator.
fixed <<   setprecision(<number>) | Round any numbers that follow to <number> decimal places.  This setting is in effect until the next number formatting manipulator.
cout.unsetf(ios::fixed); cout << setprecision(0); | Return number formatting to default.