How to use boolalpha and noboolalpha format flags to output bool value true or false in C++

1 Answer

0 votes
#include <iostream>
#include <iomanip> 

using std::cout;
using std::endl;

int main()
{
	bool b = true;
	cout << std::boolalpha << b << endl;
	cout << std::noboolalpha << b << endl;

	bool c = false;
	cout << std::boolalpha << c << endl;
	cout << std::noboolalpha << c << endl;

	return 0;
}


/*
run:

true
1
false
0

*/

 



answered Apr 7, 2018 by avibootz

Related questions

1 answer 354 views
1 answer 350 views
1 answer 351 views
1 answer 320 views
2 answers 481 views
481 views asked May 18, 2015 by avibootz
1 answer 303 views
1 answer 301 views
...