I'm having trouble getting fstream to function properly. I cannot open a text file while using any of the available parameters. My program calls mainprog() and functions correctly if I compile it as follows:
fstream openfile;
openfile("my_file.txt");
if(openfile.fail())
{
cout<<"Error opening file.";
}
else
{
mainprog();
}
But if I try to open the file with the in, out, and app parameters...
fstream openfile;
openfile("my_file.txt", fstream::in | fstream::out | fstream::app);
if(openfile.fail())
{
cout<<"Error opening file.";
}
else
{
mainprog();
}
... the program fails to open the file and displays the error message. Any suggestions?