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 153 views
153 views asked Dec 6, 2019 by avibootz
1 answer 199 views
199 views asked Oct 12, 2019 by avibootz
1 answer 111 views
1 answer 173 views
1 answer 159 views
1 answer 202 views
...