Quote Originally Posted by rajabadsha
No I am trying to understand the difference between access a file sequentially and randomly. How is it done in C? For example if I have 1000 files numbered 1 to 1000 and I want to access file number 57. If I do it sequentially I have to access the first 56. But I want to directly go to file number 57. How can it be done in C.
Assuming the record size is fixed, you'd use some simple mathematics and a call to fseek to jump forward/backwards a certain number of bytes from the beginning/end of the file. For example, assuming 100 byte records, if you wanted to access the 57th record, you'd do an fseek to the 5600 ((57-1) *100) byte and start reading from that point.