Click to See Complete Forum and Search --> : Adding on to Files
MrGameCube
June 4th, 2002, 09:57 PM
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.
Na-iem
June 5th, 2002, 05:07 AM
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
zach
June 5th, 2002, 10:05 AM
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().
MrGameCube
June 6th, 2002, 01:10 PM
thank you.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.