fprintf() weirdness?

David F. Carlson dave at micropen
Fri Dec 16 03:21:58 AEST 1988


In article <8457 at bloom-beacon.MIT.EDU>, eichin at athena.mit.edu (Mark W. Eichin) writes:
> Strange problem: I have a mail-fetch program which uses authenticated
> 	fprintf(f, "%s\r\n", buf);
> where f=fdopen(s, "r") earlier (and is not NULL...) The catch: If I
> change the fprintf to a
> 	fputs(buf,f); fputs("\r\n",f);
> 				Mark Eichin

Regardless of why the fputs works correctly (g*d only knows why), you
should not make use of *writing* to a FILE * that you show you opened
for *read* only.  Yes, you have a non-NULL FILE * but it is not correct
to write to it.

inews fodder
inews fodder
inews fodder
inews fodder
inews fodder
-- 
David F. Carlson, Micropen, Inc.
micropen!dave at ee.rochester.edu

"The faster I go, the behinder I get." --Lewis Carroll



More information about the Comp.unix.aux mailing list