Skip to main content

formatting.cpp


// Example of output formatting
// (NDE, 2013-12-29)
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
  int x = 42;
  cout << x << endl;
  cout << setw(5) << x << endl;
  cout << setfill('*') << setw(5) << x << endl;
  cout << left << setw(5) << x << endl;
  cout << setw(7) << x << endl;
  return 0;
}