*BSD News Article 66935


Return to BSD News archive

Newsgroups: comp.unix.bsd.misc,alt.unix.wizards,comp.unix.misc
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!metro!munnari.OZ.AU!spool.mu.edu!usenet.eel.ufl.edu!newsfeed.internetmci.com!howland.reston.ans.net!psinntp!psinntp!psinntp!uknet!newsfeed.ed.ac.uk!edcogsci!richard
From: richard@cogsci.ed.ac.uk (Richard Tobin)
Subject: Re: How to write end of file character into file??!
Message-ID: <Dq9ny7.DJG@cogsci.ed.ac.uk>
Organization: HCRC, University of Edinburgh
References: <4ktvmc$5d6@is05.micron.net> <4kuonh$q2@anorak.coverform.lan> <4l5le1$amd@is05.micron.net>
Date: Mon, 22 Apr 1996 13:54:06 GMT
Lines: 15
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.misc:845 alt.unix.wizards:3721 comp.unix.misc:22218

In article <4l5le1$amd@is05.micron.net> dwight@micron.net writes:
>|>     int ch;

>For a binary file, the EOF value can be a valid result from fgetc

No it can't.  getc() et al return int, not char, and the value of EOF
is an integer outside the character range.  That's why it's important
to declare the variable you read it into as int, as quoted above.

-- Richard

-- 
"Hither turn thy steps, hither come to thy death and for Camilla
receive due guerdon!  Shalt thou, even thou, die by Diana's darts?"
                                              [Virgil, Aeneid X1 855-7]