Results 1 to 13 of 13

Thread: [Resolved] File Writing Help

Threaded View

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] File Writing Help

    I have this function:

    Code:
    void addmovie() {
        char string[50] = {'\0'};
    
        ofstream outFile("C:\\test.txt", ios::out);
        if (!outFile) {
            cout << "File could not be opened!" << endl;
            exit(0);
        }
    
        cout << "String: ";
        cin.ignore();
        cin.getline(string, 50, '\n');
    
        //outFile.seekp(outFile.eof());
        outFile << string;
        outFile << '\n';
    }
    How can I make it output at the end of the file, rather than overwriting it?

    I thought about reading the file, and adding to it, then writing it back...but is there any other way?
    Last edited by The Hobo; Feb 3rd, 2003 at 11:59 AM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

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