delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2012/05/04/16:00:19

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: freopen
Date: Fri, 4 May 2012 12:41:35 -0700 (PDT)
Organization: http://groups.google.com
Lines: 25
Message-ID: <4182049f-12cf-4935-892b-daeaac0f3fd8@v2g2000vbx.googlegroups.com>
NNTP-Posting-Host: 2.174.182.95
Mime-Version: 1.0
X-Trace: posting.google.com 1336160496 27897 127.0.0.1 (4 May 2012 19:41:36 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Fri, 4 May 2012 19:41:36 +0000 (UTC)
Complaints-To: groups-abuse AT google DOT com
Injection-Info: v2g2000vbx.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: 1478
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I made the following test program to try out the freopen function:

#include <stdio.h>

main(int argc,char **argv)
{
	fprintf(stdout,"here1");

	FILE *f = freopen("stdout.dat", "wb", stdout);

	fprintf(stdout,"here2");

	freopen("con","wb",stdout);

	fprintf(stdout,"here3");

	fclose(f);

	fprintf(stdout,"here4");
}

All works fine, just the message "here4" does not appear on the
screen. How do I properly close the file "stdout.dat"?

Georg

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019