Reg中的Reg序列化和反序列化

时间:2012-06-18 12:07:47

标签: c++ boost boost-serialization

在下面的序列化和反序列化中,desrializing程序终止于下面提到的那一行。

const char *file = "aaa.bin";

std::ofstream outputstring(file,ifstream::binary);
boost::archive::binary_oarchive oa(outputstring,boost::archive::no_header);
int i =1;
oa<< i;
outputstring.close();

std::ifstream intputstring(file,ifstream::binary);
**boost::archive::binary_iarchive ia(intputstring);**   //Program is terminating here
int j;
ia >> j;
intputstring.close();

1 个答案:

答案 0 :(得分:0)

您忘记在输入存档中添加相同的标记。

boost::archive::binary_iarchive ia(intputstring, boost::archive::no_header);