Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uxc!uxc.cso.uiuc.edu!m.cs.uiuc.edu!s.cs.uiuc.edu!carroll From: carroll@s.cs.uiuc.edu Newsgroups: comp.lang.c Subject: Re: File descriptors and streams an Message-ID: <207600020@s.cs.uiuc.edu> Date: 19 Apr 89 14:23:00 GMT References: <1677@fig.bbn.com> Lines: 18 Nf-ID: #R:fig.bbn.com:1677:s.cs.uiuc.edu:207600020:000:872 Nf-From: s.cs.uiuc.edu!carroll Apr 19 09:23:00 1989 /* Written 7:57 pm Apr 17, 1989 by rsalz@bbn.com in s.cs.uiuc.edu:comp.lang.c */ /* ---------- "Re: File descriptors and streams an" ---------- */ In <207600018@s.cs.uiuc.edu> carroll@s.cs.uiuc.edu writes: > why can't you switch stdin by having another variable >FILE *tmp; >and doing >tmp = stdin; stdin = my_file; do_stuff(); stdin = tmp; Because |stdin| is not required to be an lvalue. /* End of text from s.cs.uiuc.edu:comp.lang.c */ Ah so des ka. I was confused by some early code I had written to do this. It turns out that I remembered it backwards - it would read from a FILE *, and had the ability to swap *in* stdin (e.g., in_file = stdin), as opposed to swapping *out* from stdin. Referrring back to the original problem, it might be possible to solve it by doing a similar thing - design it to read from a generic FILE *, and start with it set to stdin.