Pregunta

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"?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top