Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!deimos.cis.ksu.edu!uxc!uxc.cso.uiuc.edu!m.cs.uiuc.edu!s.cs.uiuc.edu!carroll From: carroll@s.cs.uiuc.edu Newsgroups: comp.unix.wizards Subject: Re: unix question about stdin Message-ID: <216100010@s.cs.uiuc.edu> Date: 23 Apr 89 18:09:00 GMT References: <3398@udccvax1.acs.udel.EDU> Lines: 17 Nf-ID: #R:udccvax1.acs.udel.EDU:3398:s.cs.uiuc.edu:216100010:000:958 Nf-From: s.cs.uiuc.edu!carroll Apr 23 13:09:00 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@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