Thread: Reading from tab-delimited file

  1. #1
    Registered User
    Join Date
    Feb 2005

    Reading from tab-delimited file

    Hi everyone,
    I am currently trying to put together a program that runs dijkstra's algorithm, this is not the problem however. The program must first read in data from a tab delimited file, the format of the file is:

    string <tab> string <tab> integer

    This line is repeated with different values 29 times down the page.

    I was wondering if there is a function i could use to read this information in. I then want to store the info. in an array of a data structure.

    Thankyou for your time....

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Use fgets() to read each line
    Use strtok() to break the line up into each tab-delimited string, and copy those to your struct.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 02-02-2009, 07:27 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM