Follow me

Tuesday 25 August 2020

Reading and Displaying Boolean Value as TRUE and FALSE instead of 0 ans 1 in c++ | boolapha in ios | cin setf function | c++ | cpp | fastest programming language

Reading and Displaying Boolean Value as TRUE and FALSE instead of 0 ans 1

It is used to sets the boolalpha format flag for the str stream. When the boolalpha format flag is set, bool values are inserted/extracted by their textual representation: either true or false, instead of integral values.

implamentation:
#include <bits/stdc++.h>
using namespace std;

void tfAlpha(){
    cin.setf(ios::boolalpha);
    cout.setf(ios::boolalpha);
}

int main()
{
    cout<< "before tfAlpha():" << endl;
    cout<< true<< endl;
    cout<< false<< endl;

    tfAlpha();
    
    cout<< "after tfAlpha():"<< endl;
    cout<< true<< endl;
    cout<< false<< endl;
    return 0;
}



output:   
provide your valuable feedback here.

No comments: