From: paul_h@jenson.com (Paul)
Subject: Re: Problem with C function 'system()'...
Date: 1995/12/04 [thread overview]
Message-ID: <1995Dec4.103937.64@jenson.demon.co.uk> (raw)
In-Reply-To: 49lphs$5q3@gap.cco.caltech.edu
In article <49lphs$5q3@gap.cco.caltech.edu>, carl@SOL1.GPS.CALTECH.EDU (Carl J
Lydick) writes:
> = fclose (stdout);
> = stdout = fopen (redir_file, "w");
>
> Just out of curiosity, why use fclose() and fopen() when you've got freopen(),
> which is there to do exactly what it you're attempting with fclose() and
> fopen()?
Of course freopen is shorter, I've just never used it in anger.
Nothing wrong with curiosity:
In the dim and distance past, when I was learning Vax C, I remembered doing an
experiment, "what if I close stdout", when that worked I tried adding a
"printf" statement to see what happened writing to a closed channel, finding
that also didn't crash I tried opening a new file on stdout. My (unsurprising)
conclusion was that there was nothing "special" about stdout!
So my response to the post was based on the memory of something like:
fclose (stdout);
printf ("hello");
stdout = fopen ("test", "w");
printf ("again);
Paul Harris * Senior Technical Consultant * Jenson Technology Group * Bristol
personal email to ehteam@telecall.co.uk
web home page http://www.telecall.co.uk/pharris/
fidonet 2:250/110.2 or 2:2500/502.17
keywords: alpha vax vms c amiga clueless waster
prev parent reply other threads:[~1995-12-04 5:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-11-27 5:00 Problem with C function 'system()' Carl J. Lambrecht
1995-11-29 5:00 ` Brian Hibbert
1995-11-29 5:00 ` Carl J Lydick
1995-11-29 5:00 ` Paul
1995-12-01 5:00 ` Carl J Lydick
1995-12-04 5:00 ` Paul [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox