Error 0xC0000005: Access Violation when returning from a function C++
<p>I am a beginner in this language and I have encountered this problem. After searching on net it seems it is related to memory allocation,pointers etc.. which I didn't quite understood.... Here I am trying to add data through class to a binary file...
So I would like to ask what the problem can be--></p>

<pre><code>void addques()
{
    question abc;
    ofstream fout;
    fout.open("question.txt",ios::app|ios::binary);
    cout&lt;&lt;"Enter Question!\n";
    gets(abc.ques);
    cout&lt;&lt;"Enter Options!\n";
    gets(abc.option1);gets(abc.option2);gets(abc.option3);gets(abc.option4);
    cout&lt;&lt;"Enter correct option number\n";
    cin&gt;&gt;abc.k;
    cout&lt;&lt;"Enter question nummber"; cin&gt;&gt;abc.quesno;
    fout.write((char*)&amp;abc,sizeof(abc));
    fout.close();
    cout&lt;&lt;"File closed";
}
</code></pre>

<p>It seems all the functions that have ifstream/ofstream class objects are showing this error. The last line "File Closed" is also being executed and after that errors shows up.
Could it be this line-- <code>fout.write((char*)&amp;abc,sizeof(abc))</code>; ???
Kindly Help</p>

<p>This is the related class--></p>

<pre><code>class question
{   public:
    char ques[80];
    char option1[50], option2[50], option3[50], option4[50];
    char k;
    char quesno;
};
</code></pre>

<p>For the whole program I pasted my code here 
<a href="http://pastebin.com/S7KNby0E" rel="nofollow">http://pastebin.com/S7KNby0E</a>
Kindly see it...because I was unable to do so here</p>
