|
-
June 4th, 2002, 09:57 PM
#1
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.
Future Programmer For Nintendo.
-
June 5th, 2002, 05:07 AM
#2
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
-
June 5th, 2002, 10:05 AM
#3
You could also use streams! For example:
#include <ofstream>
using std: fstream;
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().
-
June 6th, 2002, 01:10 PM
#4
Future Programmer For Nintendo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|