Skipping 2 next line when reading in from file?

This is a discussion on Skipping 2 next line when reading in from file? within the C++ Programming forums, part of the General Programming Boards category; Hey guys If I am using an ifstream to read in data, and have systematically read data on the first ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    63

    Skipping 2 next line when reading in from file?

    Hey guys
    If I am using an ifstream to read in data, and have systematically read data on the first line, How do I skip to the next line at the end of the line?
    Any ideas?
    Thanks.
    Asp

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Call getline() two times.
    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
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    hey magos getline is an ifstream method, what if he's using fread? is there any equivalent function or you just have to do it manually?

    EDIT: i.e with fseek?

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >EDIT: i.e with fseek?
    Only if you know the length of the line and the file is opened in binary mode. This would work for well formatted files, but anything else it would be easier to just read the next line and discard it.

    -Prelude
    My best code is written with the delete key.

  5. #5
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by Silvercord
    hey magos getline is an ifstream method, what if he's using fread? ...
    Originally posted by aspand
    If I am using an ifstream to read in 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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 02-02-2009, 06:27 AM
  2. Program crashes on reading a line from a file
    By bluescreen in forum C Programming
    Replies: 5
    Last Post: 10-19-2006, 05:23 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

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