The point is this: there is a file (say 1000 lines) and I need to read line number 500. Is there a way to immediately refer to a specific line ???
1 answer
If the lines are of fixed length, then you can calculate the position from which this line starts (roughly speaking, len*500 ), then set the file pointer to the desired position ( fseek(f,pos,SEEK_SET) function fseek(f,pos,SEEK_SET) , since you have C) and count what you need.
I would open the file as binary.
Well, if all the strings are different and you do not have information about their sizes — to calculate the position of the beginning of the N-th row, then only by reading a row to the required row.
|
fseek(). - Akina