How do i delete a certain part of a text file?

This is a discussion on How do i delete a certain part of a text file? within the C++ Programming forums, part of the General Programming Boards category; I want to delete a certain part of a text file using C++. I opened the file with the ios::in. ...

  1. #1
    Unregistered
    Guest

    Question How do i delete a certain part of a text file?

    I want to delete a certain part of a text file using C++. I opened the file with the ios::in. Then I used seekp() to go to the place I want. Then I wrote: "file.put(ascii(8))" to simulate a bckspace but it didn't work.
    Is it true that I must make a loop on the whole file to get the next character to my current place and put it in my current place and so on (what time consuming!!!)

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    The only way i know to do this is to read the file into an array.Place in a second array stuff that you want to keep from the first array.You can use memcpy or memmove etc. to do that. Then save the second array overwriting the file.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  2. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  3. Removing text between /* */ in a file
    By 0rion in forum C Programming
    Replies: 2
    Last Post: 04-05-2004, 09:54 AM
  4. Reading Part Of A Text File
    By Okiesmokie in forum C++ Programming
    Replies: 1
    Last Post: 03-01-2002, 01:59 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

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