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 162 views
162 views asked Dec 6, 2019 by avibootz
1 answer 219 views
219 views asked Oct 12, 2019 by avibootz
1 answer 124 views
1 answer 190 views
1 answer 173 views
1 answer 221 views
...