Reading a file usine fseek() in C
Hi,
Ok i have this question,
I am writing a program that stores information from a structure to a file (read and written in binary mode).
One of the variables in the structure is a type int.
What i want to do is open the file, use fseek() and set the origin to SEEK_END - (moves the indicator to the end of the file), then i want to go back in the file the sizeof() the structure.
That is all fine and here is the code that i use.
Code:
if ( (fseek(fp, (1 * sizeof(struct data)), SEEK_END)) != 0)
{
fprintf(stderr, "Error using fseek()");
exit(1);
}
Now the question that i want to ask is, if i read the data using fread(), does it read the file backwards (as in from the end of file to the start of file), or does it read it the normal way??
Thanks for any help.
-|- Hurgh -|-