Thread: Reading specific lines

  1. #1
    Registered User
    Join Date
    Apr 2004

    Reading specific lines

    I am working on my project and i got one problem which i cant solve :mad

    I have a file called files and inside the <files> file there are multiple lines of specific names of different files.

    ie: <files>

    I am trying to figure out how do i access that file by a specifc line lets say access line 3 <file3.dat> and put it in a variable so i can do something with it.

    Thanks in advance,

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    1) Open the file for reading.
    2) Read a line into a buffer.
    3) Increment the line count counter.
    4) Stop readin when your counter is at whatever number you want.
    5) Do something with what's in the buffer at that time.

    Consider using fgets.

    Hope is the first step on the road to disappointment.

  3. #3
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    consider thinking up cleverer names for your files ))

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading text file by line number
    By whiskedaway in forum C++ Programming
    Replies: 13
    Last Post: 06-16-2009, 10:09 AM
  2. Reading lines from a file
    By blackswan in forum C Programming
    Replies: 9
    Last Post: 04-26-2005, 04:29 PM
  3. Problems in reading binary file
    By serena in forum C Programming
    Replies: 3
    Last Post: 04-14-2005, 03:54 AM
  4. Reading Lines From a File
    By Dangerous Dave in forum C++ Programming
    Replies: 6
    Last Post: 02-22-2005, 01:17 PM
  5. Need help reading in specific type of file
    By Natase in forum C Programming
    Replies: 4
    Last Post: 09-12-2001, 08:02 PM