flip the bits : bitset flip « bitset « C++ Tutorial






#include <bitset>
#include <string>
#include <iostream>

int main ()
{
    using namespace std;

    // A bitset to hold 8-bits
    bitset <8> eightBits;
    cout << "Enter a 8-bit sequence: ";

    // Store user-supplied sequence into the bitset
    cin >> eightBits;
    cout << endl;

    // flip the bits
    eightBits.flip ();
    cout << eightBits << endl << endl;

    return 0;
}








18.4.bitset flip
18.4.1.flip the bits
18.4.2.Flip a bitset