Is using fseek
to backtrack character fscanf
operations reliable?
Like for example if I have just fscanf
-ed 10 characters but I would like to backtrack the 10 chars can I just fseek(infile, -10, SEEK_CUR)
?
For most situations it works but I seem to have problems with the character ^M
. Apparently fseek
registers it as a char but fscanf
doesn't register it, thus in my previous example a 10 char block containing a ^M
would require fseek(infile, -11, SEEK_CUR)
instead. fseek(infile, -10, SEEK_CUR)
would make bring it short by 1 character.
Why is this so?
Edit: I was using fopen
in text mode