0

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

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();
4

1 回答 1

0

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

boost::archive::binary_iarchive ia(intputstring, boost::archive::no_header);
于 2012-06-18T12:55:00.923 回答