i have problem using bitsets char when use indices.
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <bitset> using namespace std; int main() { char c = 'c'; bitset<7> b(c); cout << b << endl; for(int j = 0; j!=7;++j){ cout<<b[j]; } return 0; }
results
1000011 1100001
i must have forgotten simple. can explain why results of bitset not same when using indices , not?
your loop writes least significant bit first, opposite of done when writing numbers
Comments
Post a Comment