Set and clear format flags. - C++ File Stream

C++ examples for File Stream:cout

Introduction

The following code first sets the boolalpha flag on cout and then displays a bool value.

The following code then clears the boolalpha flag and redisplays the value.

Demo Code

#include <iostream>
using namespace std;
int main()/* ww  w . j a va2 s.c o  m*/
{
   // Set the boolalpha flag on cout.
   cout.setf(ios::boolalpha);
   cout << "The value true when the boolapha flag is set: " << true << endl;;
   // Now, clear the boolalpha flag.
   cout.unsetf(ios::boolalpha);
   cout << "The value true when the boolapha flag is cleared: " << true << endl;;
   return 0;
}

Result


Related Tutorials