CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2002
    Location
    United States
    Posts
    2

    Question 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.

  2. #2
    Join Date
    May 2002
    Location
    Cape Town, South Africa
    Posts
    5
    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

  3. #3
    Join Date
    Apr 1999
    Location
    Potsdam
    Posts
    110
    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().

  4. #4
    Join Date
    Jun 2002
    Location
    United States
    Posts
    2
    thank you.
    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
  •  





Click Here to Expand Forum to Full Width

Featured