[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: fseek on stdin fails?

On Wed, Apr 05, 2000 at 12:49:58AM +0200, Micha Feigin wrote:
> I tried to do a fseek(stdin , 0 , SEEK_END ) under linux.  On windows
> and solaris this commands cleans the input stream. Under linux I get
> an error message ilegal seek. Any ideas?

while(! feof(stdin)) { fgetc(stdin); }

It seems wrong to do a seek on stdin since the "file" size isn't known
in advance.  Maybe an expert can clear this up (or look up the C FAQ on

Also, for security reasons, I'd only ever use fgets or fgetc to read
stdin or any other untrusted "file".

| Eric G. Miller                        egm2@jps.net |
| GnuPG public key: http://www.jps.net/egm2/gpg.asc  |

Reply to: