C++二进制文件中读写bitset

这个比较简单,直接上代码:

bitset< > *b = new bitset<>();
bitset< > *c = new bitset<>();
ofstream out("I:\\test.dat",ios::binary);
out.write((char *)b,);
out.close();
ifstream in("I:\\test.dat", ios::binary);
for (int i = ; i < c[].size();)
{
char temp = ;
in.read(&temp, sizeof(char));
for (int j = ; j < ; j++)
{
bool flag = (bool)((temp >> j) & );
if (flag)
c[].set(i + j);
}
i = i + ;
}
cout << "位图读取就位" << endl;
cout << c[] << endl;
in.close(); delete b;
delete c;
上一篇:POJ - 2513 Colored Sticks(欧拉通路+并查集+字典树)


下一篇:如何使用GameObject类发送消息