1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

creating a file to read other files to extract data

Discussion in 'C' started by checkerboard, Feb 12, 2007.

  1. checkerboard

    checkerboard New Member

    Joined:
    Feb 12, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Let's say, I have 3 files, one which is a masterfile which contains the name of 2 other files I want to read data from.

    For instance:

    //Masterfile.txt

    abc.txt
    xyz.txt

    //abc.txt

    Time
    0.01 0.02 0.03 0.04

    //xyz.txt

    Money
    100
    200
    300
    400

    How do I create an input stream such that I can read just the masterfile, which in turns read abc.txt and xyz.txt and put time and money into arrays??

    Thank you.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    ReadLine the Master file and for each file names in the masterfiles just read the lines of the files to get the arrays of buffer to store as you like to.
     
  3. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Pseudo-code
    Code:
    Open masterfile for reading
    While not EOF (masterfile)
       read item as filename
       open filename for reading
       read item from filename as filetype (money/time)
       set data index to zero
       While not EOF (filename)
          read item from filename as data
          store data in filetype_array [index]
          increment index
       end while
       close filename
    end while
    close masterfile
    
     

Share This Page