-
Adding on to Files
Is there a way to add on to a file with out storing everything in that file into variables?
Also does anyone know a really good tutorial that teaches GUI?
One thing does anyone know a good tutorial/example that teachs trees and nodes?
Thanks In advance for any help anyone can offer.
-
you could simply open the file with the append flag as follows:
//start source code
FILE* myFile = fopen("test.txt", "a");
//end source code
also, if the file is in text mode, then specify that this is text mode as follows:
// start source code
FILE * myFile = fopen("test.txt", "at");
// end source code
else the file is opened in binary mode.
hope that helps you with appending to files.
Na-iem
-
You could also use streams! For example:
#include <ofstream>
using std::ofstream;
using std::ios_base;
// create file output stream, which appends data at the end of the file
ofstream out("filename.txt", ios_base::app);
or
ofstream out;
out.open("filename.txt", ios_base::app);
// send data to file
out << "String to insert at the end of the file" << std::endl;
The file will be closed if the object goes out of scope of you call ofstream::close().
-