How do I get certain part of a file?

Lokantis's Avatar, Join Date: Oct 2008
Newbie Member
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.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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