I was reading C File Handling and I ran into fseek() function. The following statement was written in the book, regarding the use of it:
int fseek(FILE *stream, long offset, int from ); //The function prototype
"On binary streams, seeks from SEEK_END may not be supported an should therefore be avoided. On text streams, the offset must be zero if from is either SEEK_CUR or SEEK_END. The offset must be a value previously returned from a call to to ftell() on the same stream if from is SEEK_SET."
I don't understand the given usage.Why the offset should be zero ?
To find the answer, I investigated and I found out that, in text streams, there is mapping of EOL(newline) from C program to different character in MSDOS. The size of newline character in C is 1 byte.
What happens when it gets written to a Notepad file?. What is the size of EOL in notepad?
I created a notepad file and did the following:
Scenario 1:
abcd
The size shown was 4 bytes. Where is newline or EOF now?
Scenario 2:
abcd
a
The size shown was 7 bytes.
Scenario 3:
abcd
a
b
The size shown was 10 bytes. How was the size calculated now?
Can anybody answer these questions?