Sam Trenholme's webpage
This article was posted to the Usenet group alt.hackers in 1995; any technical information is probably outdated.

File I/O hack...

Article: 7684 of alt.hackers
From: (The Root of All Evil)
Newsgroups: alt.hackers
Subject: File I/O hack...
Date: 19 Apr 1995 13:31:01 -0400
Organization: Virginia Tech Computer Science Dept, Blacksburg, VA
Lines: 13
Message-ID: 3n3hcl$
X-Newsreader: TIN [version 1.2 PL2]
Status: RO

Problem:  Wanted to redirect output to a file from the middle of a program,
	and then go to stdout or the file at will w/o using fprintf.  Dup
	er dup() and dup2() weren't working.
Solution: Rip apart stdio.h and examine the FILE type.	To do redirection
	(under UNIX), modify the _file field of stdout to whatever the
	_file field of the output file is.  Doesn't work when the OS
	redirects stdout, though.  Any suggestions?

Dave Mescher
GCS d,++ H>+ s+:- g+ p3 au a-- w+ v,--->! C++++,++ UU++++,A$ P-- L-
    3- E--- N++ K- W--- M V-- po Y+ t--- 5 jx R G+ !tv b++ D- B---
    e+,* u+ h- f+ r(+,++)@ !n,--- y?


Back to index