Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rds95 From: rds95@leah.Albany.Edu (Robert Seals) Newsgroups: comp.lang.c Subject: File descriptors and streams and copying thereof. Keywords: Maybe Unix specific; maybe not. Message-ID: <1743@leah.Albany.Edu> Date: 12 Apr 89 14:08:50 GMT Organization: The University at Albany, Computer Services Center Lines: 23 I want to be able to make "stdin" read from someplace besides, well, standard input in the middle of my program, and then go back to where it was again. Think "lex" and "yacc"... So what I did was this: FILE *my_file; /* sucessfully open "my_file" */ ... stdin->fd = my_file->fd; if (yyparse()) /* stuff*/ else /* stuff */ stdin->fd = 0; /* presume stdin is/was fd 0 */ ... which seems to work - most of the time. So, is this truly icky style or what, and what is the right way to do it? And BTW, if you refer me to "dup" or something like it, could you also please explain what it's supposed to do...the man pages for it are not at all clear to me. muchos, rob