The ftell() and fgetpos() functions cannot return a file position when characters are pushed back using ungetc() at the start of the file. This is because the resultant position ends up being before the start of the file, and this is not a valid position.
Function ftell() or fgetpos() fails.
Do not call ftell() or fgetpos() if you push back characters before the start of the file, unless you either read them or discard them using a reposition first.
EDC4SM