Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!hobyah.cc.uq.oz.au!bunyip.cc.uq.oz.au!munnari.OZ.AU!news.ecn.uoknor.edu!paladin.american.edu!gatech!swrinde!howland.reston.ans.net!newsfeed.internetmci.com!in2.uu.net!news.micron.net!dwight
From: dwight@micron.net (Dwight Tovey)
Newsgroups: comp.unix.bsd.misc,alt.unix.wizards,comp.unix.misc
Subject: Re: How to write end of file character into file??!
Date: 15 Apr 1996 17:06:20 GMT
Organization: Wish I had some
Lines: 39
Message-ID: <4ktvmc$5d6@is05.micron.net>
References: <xsvarshney-0604962038290001@newshub.csu.net> <4kb6sv$399@is05.micron.net> <4khh63$a3@anorak.coverform.lan>
Reply-To: dwight@micron.net
NNTP-Posting-Host: dwight.boi.micron.net
X-newsreader: xrn 8.01
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.misc:723 alt.unix.wizards:3636 comp.unix.misc:21992
In article <4khh63$a3@anorak.coverform.lan>, brian@awfulhak.demon.co.uk (Brian Somers) writes:
|> 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 ! :-)
|>
Not only are you pedantic, you are wrong. :)
With what you have, you won't process the last block of data if it is
smaller than the size of the read request.
The code I had wasn't complete either, but my intent was only to bring
attention to the feof macro.
/dwight
--
Dwight N. Tovey H&W Computer Systems, Inc.
Software Specialist III 12438 W. Bridger St. Suite 100
dwight@hwcs.com Boise, ID. 83713
or dwight@micron.net (208)377-0336
I didn't claw my way to the top of the food chain to eat vegetables!!