Swap the file contents

This is a discussion on Swap the file contents within the C Programming forums, part of the General Programming Boards category; Hi All, I would like to swap the contents of two large files without using any temporary file. However, a ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    16

    Swap the file contents

    Hi All,

    I would like to swap the contents of two large files without using any temporary file. However, a buffer can be used instead of temporary file. I could swap the file contents, but have a problem in deleting the contents of the larger file at the end.

    Please help resolve this problem.

    Thanks in advance

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    Why don't you just swap the names ?

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    16
    Great idea ! I need to improve my thinking.

    Thanks a lot

    There is a problem in opening the link.

  4. #4
    Registered User
    Join Date
    Jan 2007
    Posts
    16
    Quote Originally Posted by Desolation
    Why don't you just swap the names ?
    Thanks Desolation for your suggestion.

    Do we have any other solutions apart from renaming the files?

    Thanks in advance.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Just like swapping anything else. A to C, B to A, C to B.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    If you dont want a temporary file, and they are too large for a buffer, A = smaller file, B = larger file, C = the end of the B file (save the offset).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 11:39 PM
  2. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 04:53 AM
  3. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 01:36 PM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 05:54 PM
  5. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 08:01 PM

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