KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The following code outputs "Illegal seek": #include <stdio.h> #include <errno.h> #include <string.h> int main() { errno = 0; getchar(); getchar(); getchar(); ftell( stdin ); printf( "%s\n", strerror(errno) ); } This occurs when I run cat script | ./a.out as well as when I just run ./a.out . The problem is with ftell, of course. My question is: why does this occur? I would think stdin can be seekable. fseek also causes the same error. If stdin is not seekable, is there some way I can do the same sort of thing? Thank you for your replies.
Tags (comma-separated)
Save Edits
Cancel