I have the following program and it works but when i try to append to the file, it will not do it. Can anyone help,
Thank you
GCard
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
char buffer[256];
// open it for output then write to it
fstream myfile;
myfile.open("test3.txt",ios::out | ios::trunc);
if (myfile.is_open())
{
myfile << "This outputting a line.\n";
myfile.close();
}
// open it for input and read in
myfile.open("test3.txt",ios::in);
myfile.getline(buffer,100);
cout << "The file contains " << buffer << "\n";
myfile.close();
cout << "Click to continue";
cin.get();
//open for appending and append
myfile.open("test3.txt",ios::app);
myfile << " Hey this is another line \n";
myfile.close();
// open for input and print to screen
// open it for input and read in
myfile.open("test3.txt",ios::in);
myfile.getline(buffer,300);
cout << "The file contains " << buffer << "\n";
myfile.close();
cout << "Click to continue";
cin.get();
return 0;
}// end of main