File I/O hack...
Article: 7684 of alt.hackers From: dmescher@csugrad.cs.vt.edu (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 Approved: lucifer@hell.com Message-ID: 3n3hcl$1if@csugrad.cs.vt.edu NNTP-Posting-Host: csugrad.cs.vt.edu 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 dmescher@csugrad.cs.vt.edu 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?