I think we might also have a language barrier at work here. Kind of a common thing to have happen.
In a slightly older and more structured terminology, a database table is divided into records
. Each record contains the information about a single item in that database table.
In programming, many languages (eg, Pascal) refers to each single item as a RECORD. In C, it's a struct. A file of records would therefore be a file of struct's. The flight struct that you defined is therefore one record
. And the file is the collection of all such records.
In a simple hierarchical manner:
1 file consists of many records.
1 record consists of many fields.
Each field is a distinct data item.
When using a text file to hold records, each record occupies one single line in the file.
Each record contains the fields that are defined in your struct. The fields are separated by a delimiter
(HINT: look that term up! It means something very important and is something that we will talk about so you had better understand it!). That delimiter is often a comma, though if a field is a string that could contain a comma, then that string needs to be quoted.
I must assume that you have been given a text file to use, so whatever its
formatting is is the formatting that your program must conform to. At this point, all I could possibly do would be to guess at how it might possibly be formatted.
Originally Posted by tsahar
how i doing :
1.write function to take "text file" ? and write flight data?
2. call the flight data text file and printf code flight that the sit that availbale
"text file" should be the char string that contains the name of the text file that contains the data. You should use that char string to open that text file, which you would then read one record at a time, extracting each record's data from its fields, and then printing that data out as appropriate. You say, "that the sit that availbale". We do not understand what that is supposed to mean. There is a num_sit
field. Does that you are supposed to only output information for those records whose num_sit field was equal to a particular value? If so, then OK: if num_sit equals the right value(s), then output that record, else don't.