Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mira.net.au!vic.news.telstra.net!act.news.telstra.net!imci3!imci2!news.internetMCI.com!newsfeed.internetmci.com!news.sesqui.net!uuneo.neosoft.com!web.nmti.com!peter From: peter@nmti.com (Peter da Silva) 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 17:09:39 GMT Organization: Network/development platform support, NMTI Lines: 24 Message-ID: <4lgegj$oi3@web.nmti.com> References: <xsvarshney-0604962038290001@newshub.csu.net> <4l5le1$amd@is05.micron.net> <4l85m7$fjs@sv024.SanDiegoCA.ATTGIS.COM> <4lg9i8$8if@is05.micron.net> NNTP-Posting-Host: sonic.nmti.com Xref: euryale.cc.adfa.oz.au comp.unix.bsd.misc:790 alt.unix.wizards:3690 comp.unix.misc:22138 In article <4lg9i8$8if@is05.micron.net>, Dwight Tovey <dwight@micron.net> wrote: > At any rate, what I was trying to point out (possibly not very well) is that > testing for the EOF "value" can cause problems. Only if your code is broken: > char ch; > FILE *fp > > fp = fopen( "foo", "r" ); > while(( ch = fgetc( fp) ) > 0 ) { > putchar( ch ); > } See, the correct change to this code is to replace "char ch" with "int ch", as is described in the manuals. Also, 0xFF is a valid text character. It's a lowercase y with dieresis. -- 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