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 253 views
1 answer 241 views
1 answer 228 views
1 answer 241 views
2 answers 357 views
357 views asked May 18, 2015 by avibootz
1 answer 210 views
...