Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: redirecting output Message-ID: <1990Jun29.172429.2818@zoo.toronto.edu> Organization: U of Toronto Zoology References: <22931@dartvax.Dartmouth.EDU> Date: Fri, 29 Jun 90 17:24:29 GMT In article jason@cs.odu.edu (Jason C Austin) writes: > freopen will do the job for you. In fact the unix manual page >says that this command is mostly used for this purpose. > > freopen( "filename", "w", stdout ); You have the right idea, but you left something out. Try this instead: #define FILENAME "filename" if (freopen(FILENAME, "w", stdout) == NULL) { fprintf(stderr, "freopen on `%s' failed", FILENAME) exit(1); } God is not on your side; such a call *will* fail eventually. Life is much more pleasant if your code copes properly. -- "Either NFS must be scrapped or NFS | Henry Spencer at U of Toronto Zoology must be changed." -John K. Ousterhout | henry@zoo.toronto.edu utzoo!henry