質問

So I stored a struct to a sequential file in this format "%d %s %s %f" what I am wondering is , if I am seeking the last record from a file , and I use fseek(*val,offset*-1,Seek_end when i use fscanf would it read backwards? So I would have to read "%f %s %s %d"?

役に立ちましたか?

解決

No, it doesn't cause subsequent reads to go backwards, reads always go forwards.

All it does is sets the file pointer to that distance from the end of file. So, if you have a file containing the English letters and you seek with -5 and SEEK_END, the next reads will give you vwxyz in that order.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top