Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   creating a file to read other files to extract data (http://www.go4expert.com/forums/creating-file-read-files-extract-data-t2967/)

checkerboard 12Feb2007 20:57

creating a file to read other files to extract data
 
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.

shabbir 12Feb2007 22:46

Re: creating a file to read other files to extract data
 
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.

DaWei 13Feb2007 01:57

Re: creating a file to read other files to extract data
 
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



All times are GMT +5.5. The time now is 19:56.