Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.mel.connect.com.au!news.mel.aone.net.au!imci4!newsfeed.internetmci.com!news.mathworks.com!nntp.primenet.com!arclight.uoregon.edu!dispatch.news.demon.net!demon!awfulhak.demon.co.uk!awfulhak.demon.co.uk!awfulhak.demon.co.uk!not-for-mail From: brian@awfulhak.demon.co.uk (Brian Somers) Newsgroups: comp.unix.bsd.freebsd.misc,gnu.g++.help Subject: Re: g++2.7.2 error on freebsd Followup-To: comp.unix.bsd.freebsd.misc,gnu.g++.help Date: 9 Sep 1996 10:34:49 +0100 Organization: Coverform Ltd. Lines: 44 Distribution: world Message-ID: <510obp$9m@anorak.coverform.lan> References: <8414360547401@maverick.mcs.anl.gov> <50ee1f$dp@anorak.coverform.lan> <50t8s1$lhr@news1.infinet.com> NNTP-Posting-Host: localhost.coverform.lan X-NNTP-Posting-Host: awfulhak.demon.co.uk X-Newsreader: TIN [version 1.2 PL2] Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:26980 gnu.g++.help:13277 Mike Harrold (ao@infinet.com) wrote: : 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! :-) Pardon ? : : 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>)? Eh, 'cos it's C code ? -- Brian <brian@awfulhak.demon.co.uk> Don't _EVER_ lose your sense of humour....