Thread: Delete A line In An ASCII File

  1. #1
    Unregistered
    Guest

    Delete A line In An ASCII File

    How can I delete one or more lines in an ascii file?

  2. #2
    Unregistered
    Guest
    Do you know what is on the lines you want to delete? Or Will it always be data on the same line that you want to delete.

    The method would be, read the file, output to new file, replace old file with new file.

    Between the read and the output you remove the line(s) you don't want, how you do this is really dependent upon the question above... unless for reasons I can't fathom you feel like deleting random lines of text from the file.

    To remove a line of text where you know what the line says, I guess the method would be to use a loop to read a line into a string, then output it to the output file within an if statement using strncmp, if the strings match, have the if statement stop the output before you write to the new file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM