Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!news.sdsmt.edu!news.mid.net!mr.net!www.nntp.primenet.com!nntp.primenet.com!cs.utexas.edu!howland.erols.net!newsfeed.internetmci.com!news.infinet.com!ao
From: ao@infinet.com (Mike Harrold)
Newsgroups: comp.unix.bsd.freebsd.misc,gnu.g++.help
Subject: Re: g++2.7.2 error on freebsd
Date: 8 Sep 1996 01:52:01 GMT
Organization: InfiNet
Lines: 43
Distribution: world
Message-ID: <50t8s1$lhr@news1.infinet.com>
References: <8414360547401@maverick.mcs.anl.gov> <50ee1f$dp@anorak.coverform.lan>
NNTP-Posting-Host: user2.infinet.com
X-Newsreader: TIN [version 1.2 PL2]
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:26807 gnu.g++.help:13242
Brian Somers (brian@awfulhak.demon.co.uk) wrote:
: Satish Balay (balay@maverick.mcs.anl.gov) wrote:
[snip]
: Hmm, it couldn't work correctly - it doesn't close fp - or check to see if
: it actually opened "x". And why is it flushing stdout ?
: The correct code, I suspect, is:
: #include <stdio.h>
: #include <stdarg.h>
: #include <stdlib.h>
: int NewPrintf( char *format, ... )
: {
: int rank;
: va_list Argp;
: FILE *fp;
: if( fp = fopen( "x", "w" ), !fp )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ARGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH! :-)
: return 1;
: va_start( Argp, format );
: vfprintf( fp, (char *)format, Argp );
: va_end( Argp );
: fclose( fp );
: return 0;
: }
I have simpler questions... why is he using FILEs? Why is he using C header
files (eg <stdlib.h>) and not C++ header files (eg <cstdlib>)?
/Mike
--
+--------------------------------------------------------------------------+
| Take the cheese to sickbay, the Doctor should take a look at it as soon |
| as possible. -- B'lanna Torres - Star Trek Voyager - 'Learning Curve'. |
+--------------------------------------------------------------------------+