C++ examples for File Stream:cout
Writing Your Own Stream Manipulators
#include <iostream> #include <iomanip> #include <string> using namespace std; // make floating-point output look normal inline ios_base& floatnormal(ios_base& io) { io.setf(0, ios_base::floatfield);//w w w . j a v a2 s . co m return(io); } int main() { ios_base::fmtflags flags = cout.flags(); double pi = 3.14159265; cout << "pi = " << scientific // Scientific mode << pi * 1000 << '\n'; cout << "pi = " << floatnormal << pi << '\n'; cout.flags(flags); }