unix question about stdin
carroll at s.cs.uiuc.edu
carroll at s.cs.uiuc.edu
Mon Apr 24 04:09:00 AEST 1989
Having already made myself look like an idiot on a related subject, I'll
try again :-)
I think you are looking at the problem backwards. You want to be able to read
from several files, one of which happens to be stdin. I strongly suggest
that you use generic file manipulations (e.g., fprintf, fgetc, etc.) on a
global (FILE *). Then the solution is simple - init the global to stdin,
later set it to the other file you want to read from, and then when you
are done, set it back to stdin (which is still there). In fact, you could
even write a set of stack routines that would allow you to "push" (FILE *)'s
and retrieve them on EOF without little difficulty. We did this for a low
level programming class - I can send you example code if you want.
Alan M. Carroll "And then you say,
carroll at s.cs.uiuc.edu We have the Moon, so now the Stars..." - YES
CS Grad / U of Ill @ Urbana ...{ucbvax,pur-ee,convex}!s.cs.uiuc.edu!carroll
More information about the Comp.unix.wizards
mailing list