我正在使用 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
=====================================================================================