writing to the beginning of the file

This is a discussion on writing to the beginning of the file within the C++ Programming forums, part of the General Programming Boards category; I need to write back to the beginning of a file with overwritting it. Currently it opens without truncation but ...

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    32

    writing to the beginning of the file

    I need to write back to the beginning of a file with overwritting it.
    Currently it opens without truncation but writes to the end of the file. How can I set it to the beginning?

    Code:
    outfile.open(fileName, ios::in|ios::nocreate|ios::app);
    thanx

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Remove the ios::app flag.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  4. Writing input from a file into shared memory
    By RazielX in forum C Programming
    Replies: 2
    Last Post: 09-23-2004, 12:34 PM

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