Define your own ostream variable : ostream « File Stream « C++ Tutorial






#include<iostream.h>
ostream & setthex(ostream & stream)
{
  stream.setf(ios::hex|ios::uppercase|ios::showbase);
  return stream;
}
ostream & reset(ostream & stream)
{
  stream.unsetf(ios::hex|ios::uppercase|ios::showbase);
  return stream;
}
main()
{
  cout<<setthex<<200<<'\n';
  cout<<reset<<200<<'\n';
  return 0;
}
200
200








12.11.ostream
12.11.1.Define your own ostream variable
12.11.2.file descriptor out buffer
12.11.3.stream for hexadecimal standard output
12.11.4.Switch between decimal and hexadecimal output
12.11.5.Hex out stream
12.11.6.Redirect ouput into the file
12.11.7.Open file ''example.dat'' for reading and writing