I am trying to learn dynamic file access. My code is as follows:
int main()
{
    dtbrec xrec; // class object
    fstream flh;
    // Doesn't create a new file unless ios::trunc is also given.
    flh.open("database.txt", ios::in | ios::out | ios::binary);
    flh.seekp(0,ios::end);
    xrec.getdata();
    flh.write((char*)&xrec, sizeof(dtbrec));
    flh.close();
}
I thought that fstream by default creates a new file 'database.txt' if it doesn't exist. Any ideas as to what could be wrong?