delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
From: | Georg <dosusb AT googlemail DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: freopen |
Date: | Sat, 5 May 2012 07:27:54 -0700 (PDT) |
Organization: | http://groups.google.com |
Lines: | 28 |
Message-ID: | <23dc3b7d-8f8e-4154-aabb-d01c3b36af54@t20g2000vbx.googlegroups.com> |
References: | <4182049f-12cf-4935-892b-daeaac0f3fd8 AT v2g2000vbx DOT googlegroups DOT com> |
<a0j2npFlg6U1 AT mid DOT dfncis DOT de> <3394f14f-8b8e-4b81-baa2-1f986b13d4eb AT p21g2000vby DOT googlegroups DOT com> | |
<a0kkcvF69jU1 AT mid DOT dfncis DOT de> | |
NNTP-Posting-Host: | 2.174.182.95 |
Mime-Version: | 1.0 |
X-Trace: | posting.google.com 1336228074 19101 127.0.0.1 (5 May 2012 14:27:54 GMT) |
X-Complaints-To: | groups-abuse AT google DOT com |
NNTP-Posting-Date: | Sat, 5 May 2012 14:27:54 +0000 (UTC) |
Complaints-To: | groups-abuse AT google DOT com |
Injection-Info: | t20g2000vbx.googlegroups.com; posting-host=2.174.182.95; posting-account=v5xbdQoAAAAOGc9Ccc-kLZyobvPlN3Qr |
User-Agent: | G2/1.0 |
X-HTTP-UserAgent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.4) |
Gecko/20091016 Firefox/3.5.4,gzip(gfe) | |
Bytes: | 2409 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
X-MIME-Autoconverted: | from quoted-printable to 8bit by delorie.com id q45Ej291030047 |
Reply-To: | djgpp AT delorie DOT com |
On May 5, 2:22 pm, Hans-Bernhard Bröker <HBBroe DOT DOT DOT AT t-online DOT de> wrote: > On 05.05.2012 08:01, Georg wrote: > > > "FILE *freopen(const char *filename, const char *mode, FILE *file); > > > Description > > > This function closes file if it was open, then opens a new file like > > fopen(filename, mode) (see section fopen) but it reuses file." > > > I read this description that the third parameter of freopen is closed, > > in my example it is stdout. The resulting handle is associated with > > stdout.dat and I do not see that this gets closed. > > I think you overlooked that in your example, you called freopen() > _twice_. The first time you replaced the stdout handle by the file > "stdout.dat", the second time you closed that and replaced stdout by a > handle to the console. > > When your example fclosed() the FILE *f returned by the first freopen(), > you actually closed stdout itself. I guess I still do not understand it completely but when I remove fclose(f); it works. And since you said the second freopen() closes "stdout.dat" I do not need to explicitly close that. Thank you. Georg
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |