Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help - multiple variable length records in one data file.

Status
Not open for further replies.

ColW

Programmer
Oct 3, 2003
2
GB
i'm trying to write a porgram that reads records from a transaction file then validates them, writes them to a new file before sorting the records in order depending on the key field used.

problem is you need to use 3 structures for the 3 types of record, but how do you know which structure to read record into if you don't know which type of record it is and how do oyu know which type of record it is if you don't know which structure to read it inot.

all this is done from a line sequential file.

sorry if this is confused, but so am I.
 
I would create a union containing the 3 structures and read the data into it. It will be big enough to hold the largest record. Once you have read the record in, you will need to determine what kind is record it is maybe by a common field in the structures or the length of data read in.

Hope this helps. CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top