我使用boost gzip来读取压缩文件。当我第一次打电话时,我的程序运行正常。但是当我第二次调用相同的功能时。它失败。我不知道为什么它只能工作一次。谢谢!
void readcheckfile(const char* _checkname,queue<Graphnode> &_q)
{
int _dep;
int _val;
Graphnode currentNode;
cout<<"hererererererer\n";
fstream _checkfile(_checkname, fstream::in | fstream::binary);
cout<<"tthererererererer\n";
std::stringstream _data;
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
in.push(boost::iostreams::gzip_decompressor());
in.push(_checkfile);
boost::iostreams::copy(in, _data);
cout<<"aaaatthererererererer\n";
//fstream _checkfile;
//_checkfile.open(_checkname,fstream::in);
_data>>_dep;
while(_data.good())
{
currentNode.depth=(unsigned char)_dep;
_data>>_val;
currentNode.x=(unsigned char)_val;
for(i=0;i<16;i++)
{
_data>>_val;
currentNode.state[i]=(unsigned char)_val;
}
_q.push(currentNode);
}
_checkfile.close();
//exit(0);
}
我打电话两次 终端返回:
hererererererer
tthererererererer
aaaatthererererererer
hererererererer
tthererererererer
libc++abi.dylib: terminate called throwing an exception
=====================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= EXIT CODE: 6
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
=====================================================================================