Create custom output format : cout custom « Console « C++






Create custom output format

Create custom output format

#include <iostream>
using namespace std;

ostream &setup(ostream &stream)
{
  stream.width(10);
  stream.precision(4);
  stream.fill('*');

  return stream;
}

int main()
{
  cout << setup << 123.123456;

  return 0;
}

           
       








Related examples in the same category

1.Create an output manipulator. Create an output manipulator.
2.A manipulator: turns on the showbase flag and sets output to hexadecimal
3.A simple output manipulator: sethexA simple output manipulator: sethex
4.Define operator for coutDefine operator for cout
5.Custom cout output manipulatorCustom cout output manipulator