简单例子:
#include "stdafx.h" #include <iostream> #include <vector> #include <bitset> #include "ref.h" using namespace std; int main() { std::bitset<8> bTest('a'); system("pause"); return 0; }
这里通过将'a'char类型隐式转化为unsigned long long构造bTest;'a'在内存的二进制数据为01100001;
调试看bTest: 与内存的数据对应上
所以要去一块内存的二进制数据就可以通过memcpy将这块内存拷贝到char数组里;再一个个通过上述方法取出一个个字符在内存的二进制数据