How do I get certain part of a file?
I am using C.
Say I have a FILE datatype studentRecord in the following format " EntryIndex. lastname, firstname: score" for example "12. Simpson, Homer: 15". That is one record. Records are separated by space. Suppose the user enters number 12, how do I print out that exact record number 12? Logically I would think do somehing like
go through the file character by character, if find combination like "studentNumber + "."" print out characters starting from that point until a third space character.
Re: How do I get certain part of a file?
Read the complete file into some structure which is equivalent to the data in the file and then either arrange them in a Linked List or even array and then traversing through it would help you get the needed record.
The above solution would work assume you have few records and not thousands of them or else you may run out of memory
|All times are GMT +5.5. The time now is 13:45.|