What is the difference between sequential access file and random access file
What is the difference between sequential access file and random access file
Are these a bunch of homework questions? STFW.
If you understand what you're doing, you're not learning anything.
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.Originally Posted by rajabadsha
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens