c++ how to use bitset code example
Example 1: bitset c++
#include <iostream>
#include <bitset>
int main() {
std::bitset<8> byte1 = bitset<8>(97);
std::bitset<8> byte2 = bitset<8>("0001101")
std::cout << byte1;
}
Example 2: bitset declaration c++
#include <iostream>
#include <string>
#include <bitset>
int main ()
{
std::bitset<16> foo;
std::bitset<16> bar (0xfa2);
std::bitset<16> baz (std::string("0101111001"));
std::cout << "foo: " << foo << '\n';
std::cout << "bar: " << bar << '\n';
std::cout << "baz: " << baz << '\n';
return 0;
}