L
L
Loligan2015-06-09 09:34:53
Qt
Loligan, 2015-06-09 09:34:53

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);
}

The problem is in this function. But I'm not sure where exactly:

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

1 answer(s)
F
FloorZ, 2015-06-09
@FloorZ

The problem is in this function. But I'm not sure where exactly:

Put a breakpoint in a function and work it out step by step in debuggers?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question