*BSD News Article 65441


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!spool.mu.edu!howland.reston.ans.net!tank.news.pipex.net!pipex!dispatch.news.demon.net!demon!awfulhak.demon.co.uk!awfulhak.demon.co.uk!not-for-mail
From: brian@awfulhak.demon.co.uk (Brian Somers)
Newsgroups: comp.unix.bsd.misc,alt.unix.wizards,comp.unix.misc
Subject: Re: How to write end of file character into file??!
Followup-To: comp.unix.bsd.misc,alt.unix.wizards,comp.unix.misc
Date: 11 Apr 1996 00:45:07 +0100
Organization: Coverform Ltd.
Lines: 26
Message-ID: <4khh63$a3@anorak.coverform.lan>
References: <xsvarshney-0604962038290001@newshub.csu.net> <4kb6sv$399@is05.micron.net>
NNTP-Posting-Host: anorak.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.misc:670 alt.unix.wizards:3596 comp.unix.misc:21889

Dwight Tovey (dwight@micron.net) wrote:
[stuff deleted]

: data_f = fopen( "input", "r" );
: while( !feof( data_f )) {
:   fread(....)
:    .....
: }

: fclose( data_f );

Nope, you'd be better off writing

data_f = fopen( "input", "r" );
while( fread(....), !feof( data_f ) ) {
   .....
}

fclose( data_f )

And don't ever call me pedantic ! :-)

--
Brian <brian@awfulhak.demon.co.uk>
Don't _EVER_ lose your sense of humour....