Yes, lseek
will change the seek pointer. No, it is not equivalent to ungetc()
.
fseek(stdin, -1, SEEK_CUR)
comes closer to ungetc()
, but still isn't identical.
Вопрос
Usually lseek
doesn't work on stdin
.
But, what if I run my program like this:
./a.out < filename
Now stdin
is a file and not keyboard.
Will lseek
work there?
Can I do
lseek(0, -1, SEEK_CUR)
and get the same effect like
ungetc()
?
Решение
Yes, lseek
will change the seek pointer. No, it is not equivalent to ungetc()
.
fseek(stdin, -1, SEEK_CUR)
comes closer to ungetc()
, but still isn't identical.