How to set all bits of bitset to 0 in C++

1 Answer

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

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

int main()
{
	std::bitset<4> bs(string("1011"));

	cout << bs << endl;
	bs.reset();
	cout << bs << endl;

	return 0;
}


/*
run:

1011
0000

*/

 



answered Jul 17, 2018 by avibootz

Related questions

1 answer 227 views
227 views asked Jul 16, 2018 by avibootz
1 answer 159 views
1 answer 202 views
1 answer 167 views
1 answer 186 views
1 answer 205 views
...