I just noticed a small typo in the solution to Problem 3. In line 4, I wrote fin.write(...), it should be FileOut.write(...).

And before return 0, I forgot to place FileOut.close().

So, the code becomes :
Code: c++
int WriteStruct(Student A)
{      ofstream FileOut("xyz.txt",ios::binary);
        if (ios::fail) return -1;
        FileOut.write((char *)(&A), sizeof(A));
        FileOut.close();
        return 0;
}