file I/O

This is a discussion on file I/O within the C++ Programming forums, part of the General Programming Boards category; how can I reopen a file later in a program and ot erase everything in it??????? Ofstream doesn't work it ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    208

    file I/O

    how can I reopen a file later in a program and ot erase everything in it???????
    Ofstream doesn't work it erases everything
    Jeff Paddon
    Undergraduate Research Assistant
    Physics Department
    St. Francis Xavier University

  2. #2
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    359
    Code:
    #include <fstream.h>
    
    int main(void)
    {
      const char FILE_NAME[]="Test.txt";  
    
      fstream File( FILE_NAME, ios::in || ios::out );
    
      return 0;
    }

  3. #3
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107

    Re: file I/O

    Originally posted by kas2002
    Ofstream doesn't work it erases everything
    Yes it does, just give ios::app flag to it.
    Code:
    ofstream output("code.cpp",ios::app);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-30-2004, 11:21 PM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM
  5. advice on file i/o
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 04:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21