[comp.lang.c] File descriptors and streams an

carroll@s.cs.uiuc.edu (04/19/89)

/* 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.