Thread: Removing a header from a file

  1. #1
    JamesK
    Guest

    Removing a header from a file

    how would you go about removing a header from a file?I have a bunch of files all with various headers some 5 or 6 lines long then the file and i need them removed.
    its something like this
    1.text text
    2.text test
    3.testing jibberish
    4.junk

    heres the start of the file
    i've tryed scanning for the blank line but that wasn't 2 good and i would scan for parts of the text but its not always the same. i need to remove lines 1 2 3 and 4 but there not labeled like that

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Read 4 junk lines using getline() then start reading the 'real' data. Of course this only applies to files with four header lines then the data.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    JamesK
    Guest
    thats where my problem is, the amount of junk lines varies, i never know how many there will be

  4. #4
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    >> i've tryed scanning for the blank line but that wasn't 2 good

    Post your code, perhaps someone can help you.

    //edit

    If the blank line is the first blank line in the file, then search for the first occurence of "\n\n", and voila.
    Last edited by The Dog; 05-26-2003 at 05:17 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Replies: 6
    Last Post: 04-02-2002, 05:46 AM