Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.bhp.com.au!mel.dit.csiro.au!munnari.OZ.AU!news.ecn.uoknor.edu!paladin.american.edu!gatech!newsfeed.internetmci.com!news.mathworks.com!uunet!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: 22 Apr 1996 15:55:18 GMT Organization: Wish I had some Lines: 34 Message-ID: <4lga56$8if@is05.micron.net> References: <xsvarshney-0604962038290001@newshub.csu.net> <4ktvmc$5d6@is05.micron.net> <4kuonh$q2@anorak.coverform.lan> <4l5le1$amd@is05.micron.net> <4l90bh$5nu@web.nmti.com> 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:778 alt.unix.wizards:3679 comp.unix.misc:22112 In article <4l90bh$5nu@web.nmti.com>, peter@nmti.com (Peter da Silva) writes: |> In article <4l5le1$amd@is05.micron.net>, |> Dwight Tovey <dwight@micron.net> wrote: |> > For a binary file, the EOF value can |> > be a valid result from fgetc (or whatever read), |> |> Not unless you've made the mistake of declaring the variable you're stuffing |> the return value from fgetc() in (char). fgetc() returns an (int), and the |> value EOF is defined to not match any valid character. |> |> -- |> Peter da Silva (NIC: PJD2) `-_-' 1601 Industrial Boulevard |> Bailey Network Management 'U` Sugar Land, TX 77487-5013 |> +1 713 274 5180 "Har du kramat din varg idag?" USA |> Bailey pays for my technical expertise. My opinions probably scare them Hi Peter In response to another post, I've already posted some sample code to illustrate what I was talking about. Yes it is a mistake to stuff the fgetc result into a char before testing the result, but it still gets done. Several times I've seen people use a char, since that is what they expect to get back. The first line of the man page for *getc states that they "return the next character". This can be confusing to people that are possibly new to programming and Unix. The solution I posted was not correct and it meant to be. It was only meant to point out 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!!