I have a mini-assignment to do at University over the next two weeks or so, to be written in C, but the trouble is, I haven't written a line of C in nearly 2 years, so I am extremely rusty. Anyway, here is what I need help with:
I have data in a file in the following format (comma seperated)
Code:
Origin,Destination,Flight No.,Aircraft type,Days of week,Departure time,Arrival time,Begin Date,End Date
Essentially, what I have to do is read the data contained in this file into an array in order to run a search function on it.
What the program is required to do is to take in the Origin and Destination, and display all of the flights that go between these two places, along with the rest of the information given above.
The file is absolutely huge, but we were told that if we can get it to work on about 10 lines of data, there is no reason why it shouldn't work with a larger file.
I have absolutely no idea how to go about reading this data into an array. I have a C book which briefly covers opening files, but it doesn't mention comma-seperated data in files.
We were told that strtok() is the best way to go about doing this, and I have
found an example of using it here, but I haven't got a clue how to read comma-seperated text in. We are using standard C for this exercise, not C++.
Any help on this really would be appreciated, as I have absolutely no idea how to do this. Once I have the data in an array, I should be able to muddle through it, but getting started is the problem.
Thanks in advance for your help.
Cheers,
Malcolm