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 243 views
1 answer 233 views
1 answer 219 views
1 answer 231 views
2 answers 349 views
349 views asked May 18, 2015 by avibootz
1 answer 203 views
...