Delete string from textfile

This is a discussion on Delete string from textfile within the C Programming forums, part of the General Programming Boards category; Hello everyone, Just want to check with all of you. Let say if I used ftell and fseek to position ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    58

    Delete string from textfile

    Hello everyone,

    Just want to check with all of you. Let say if I used ftell and fseek to position the pointer, can I use it to delete all the text that is beyond the position? Any suggestion?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    No you can't.

    Anything more complicated than just appending to the end of the file requires you to recreate the file by reading the old file and applying your "edits" as you go (whether it be insert, modify or delete).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  4. problems with overloaded '+' again
    By Brain Cell in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2005, 05:13 PM
  5. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-26-2003, 11:03 PM

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