hey everyone, i am ready to throw my computer at a wall for this.
So if you want to help me save my sanity and a few hundred bucks in a new computer, please assist me on this one.
Basically, the main problem is that when i open a txt file for output to write a simple message to it, it wipes out the contents in it and does not write the message to it. Also, i don't get an error message when checking if the output file was opened correctly, so i assume it was opened correctly(?), it
I am also reading input for this program, but that part is working well. Maybe the way i did this is affecting the output part??
ifstream input("quadratic.txt");
if (input.fail())
{
cout<<"Error opening the file for input";
return 0;
}
ofstream outfile;
outfile.open("IamME.txt");
if (outfile.fail())
{
cout << "Error opening file for output";
}
outfile<<"THIS IS A LINE OF COKE";
Basically you can open files in various modes and it sounds like the default action for open() that you are using is write mode. You probably want APPEND mode which will append to the file instead of clearing it before writing to it, which is what standard write mode does =)
Try this...
1 2 3 4 5 6 7 8 9 10 11 12 13 14
ifstream input("quadratic.txt");
if (input.fail())
{
cout<<"Error opening the file for input";
return 0;
}
ofstream outfile;
outfile.open("IamME.txt", ifstream::app);
if (outfile.fail())
{
cout << "Error opening file for output";
}
outfile<<"THIS IS A LINE OF COKE";