Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!sdrc!thor!scjones From: scjones@thor (Larry Jones) Newsgroups: comp.lang.c Subject: Re: redirecting output Message-ID: <109@thor> Date: 29 Jun 90 12:36:17 GMT References: <22931@dartvax.Dartmouth.EDU> Distribution: na Organization: SDRC, Cincinnati Lines: 25 In article , jason@cs.odu.edu (Jason C Austin) writes: > freopen( "filename", "w", stdout ); > > Anything sent to stdout after this command is executed will go > to filename. The function returns the previous value of stdout, so > you'll probably want to keep it and restore the value, if you want to > start sending things back to the screen. No, freopen does NOT return the previous value of stdout, it returns the current value of stdout (which should, I think, be the same). The old file has been CLOSED, so there is no way to continue sending data to it without reopening it, which you probably can't do since you probably don't know its name. freopen is portable and works fine for a permanent diversion. For a temporary diversion, you have to do something system dependent. On most unix systems you need to use fileno, dup, and fdopen to make it all work. ---- Larry Jones UUCP: uunet!sdrc!scjones SDRC scjones@SDRC.UU.NET 2000 Eastman Dr. BIX: ltl Milford, OH 45150-2789 AT&T: (513) 576-2070 "This probably just goes to show something, but I sure don't know what." -Calvin