Thread: Reading Data

  1. #1
    Registered User
    Join Date
    Aug 2001

    Reading Data

    I am working on a script to write a file that i want to import in my game im writeing.

    Im laying out the info like so

    Short Name
    1 1 1 1 1 0 0 0 0 1 0 0
    5.0 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5
    0 0 0 0 0 0 0 0 0 0

    Will i have problems reading this, or is it easy to just read in one value at a time? Im concerned about when some of the values become double or tripple digit, Will I have a hard time sorting them out? Should i make everything on a seperate line? Im just trying to plany ahead, and dont know what I need to account for.

  2. #2
    Registered User
    Join Date
    Aug 2001
    You should be able to read/write the file as presented using single data read/writes without much trouble. If the number of variables per line is constant it will be easier, but can be done relatively straightforward even if there is a variable number of values on a given line in a given record.

    >> to read in first line
    ignore() to remove new line char
    getline() to read in second line
    loop with >> to read in ints in third line
    loop with >> to read in doubles in fourth line
    loop with >> to read in ints in fifth line
    >> to read in int in last line.

    If there is a standard size to the strings and a standard quantity to the various numbers on the various lines you could even create a struct/class to hold all the data and read/write with a single call using read()/write() althought the file will probably be in binary and therefore very difficult for you to read, although the computer will have no problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading large complicated data files
    By dodzy in forum C Programming
    Replies: 16
    Last Post: 05-17-2006, 04:57 PM
  2. accessing my com port, writing and reading data
    By shoobsie in forum C Programming
    Replies: 7
    Last Post: 09-16-2005, 03:29 PM
  3. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  4. reading data format into program
    By lambs4 in forum C Programming
    Replies: 1
    Last Post: 10-23-2003, 02:27 PM
  5. Binary data reading
    By jdinger in forum C++ Programming
    Replies: 3
    Last Post: 03-07-2002, 06:56 PM