|
fmtflags.h - Example 8-1 fmtflags header file |
// File: fmtflags.h
#ifndef FMTFLAGS_H
#define FMTFLAGS_H
#include <iostream>
using namespace std;
void show_fmtflags(ios_base& stream) {
if (&stream == &cout) cout << "cout ";
if (&stream == &cerr) cout << "cerr ";
if (&stream == &clog) cout << "clog ";
if (&stream == &cin) cout << "cin ";
cout << "ios_base::fmtflags set: ";
if (stream.flags() & ios::boolalpha) cout << "boolalpha ";
if (stream.flags() & ios::dec) cout << "dec ";
if (stream.flags() & ios::fixed) cout << "fixed ";
if (stream.flags() & ios::hex) cout << "hex ";
if (stream.flags() & ios::internal) cout << "internal ";
if (stream.flags() & ios::left) cout << "left ";
if (stream.flags() & ios::oct) cout << "oct ";
if (stream.flags() & ios::right) cout << "right ";
if (stream.flags() & ios::scientific) cout << "scientific ";
if (stream.flags() & ios::showbase) cout << "showbase ";
if (stream.flags() & ios::showpoint) cout << "showpoint ";
if (stream.flags() & ios::showpos) cout << "showpos ";
if (stream.flags() & ios::skipws) cout << "skipws ";
if (stream.flags() & ios::unitbuf) cout << "unitbuf ";
if (stream.flags() & ios::uppercase) cout << "uppercase ";
cout << endl;
}
#endif
CIS27: Programming in C++ Instructor: Joe Bentley