How to flip bits in bitset with C++

1 Answer

0 votes
#include <iostream>
#include <bitset>
#include <string>

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

int main()
{
	std::bitset<16> bo(std::string("1011"));
	
	cout << bo << endl;

	bo.flip();
	cout << bo << endl;
	
	return 0;
}


/*
run:

0000000000001011
1111111111110100

*/

 



answered Apr 18, 2018 by avibootz

Related questions

1 answer 264 views
264 views asked Dec 6, 2019 by avibootz
1 answer 309 views
309 views asked Oct 12, 2019 by avibootz
1 answer 226 views
1 answer 277 views
1 answer 275 views
1 answer 327 views
...