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:
No comments:
Post a Comment