Answer the question
In order to leave comments, you need to log in
Problem loading binary file, project closes unexpectedly when compiling?
If you follow through DEBUG, then it refers to a bold line
push_back(const value_type& __x)
{
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
{
this->_M_impl.construct(this->_M_impl._M_finish, __x);
++this->_M_impl._M_finish;
}
else
_M_insert_aux(end(), __x);
}
void function::load_message()
{
ifstream file("messages.dat", ios::binary);
if(!file.is_open()){
cout << "Can't open file" << "messages.dat" << endl;
return;
}
int msg_size = 0;
file.read((char *)&msg_size, sizeof(int));
while(!file.eof() && msg_size > 0){
message *_msg = new message();
file >> *_msg;
//cout << "Read new message " << _msg->getText_message();
msg_v.push_back(_msg);
msg_size --;
}
file.close();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question