Cloud Stack Ninja

#if _ITERATOR_DEBUG_LEVEL == 2
    if (_Myproxy) { // proxy allocated, drain it
        _Lockit _Lock(_LOCK_DEBUG);

        for (auto _Pnext = &_Myproxy->_Myfirstiter; *_Pnext; *_Pnext = (*_Pnext)->_Mynextiter) { 
            (*_Pnext)->_Myproxy = nullptr;
        }

        _Myproxy->_Myfirstiter = nullptr;
    }
#endif

I have this code and the problem is that I got this exception all the time I'm trying to write into file after reading previous info from it:

ifstream in(fileName, ios::binary);
if(in.is_open()) {
    while (!in.eof()) {
        in.read((char*)&tempUser, sizeof(User));
    }
}
else {
    cout << "Cannot open file" << endl;
}
in.close();

ofstream out(fileName, ios::binary | ios::app);
if (out.is_open()) {
    out.write((char*)this, sizeof(User));
}
else {
    cout << "Cannot open file" << endl;
}
out.close();

It works fine, if I set ios::ate for ifstream, but in this case I don't read file because of pointer in the end.



Read more here: https://stackoverflow.com/questions/64405016/why-do-i-have-unhandled-exception-pnext-after-attempt-to-write-into-a-file

Content Attribution

This content was originally published by misxka at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: