Create an output manipulator. : cout custom « Console « C++






Create an output manipulator.

Create an output manipulator.


 
#include <iostream> 
#include <iomanip> 
using namespace std; 
 
ostream &setup(ostream &stream) 
{ 
  stream.setf(ios::left); 
  stream << setw(10) << setfill('$'); 
  return stream; 
} 
 
int main() 
{ 
  cout << 10 << " " << setup << 10; 
 
  return 0; 
}

           
       








Related examples in the same category

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