gets(3) nonsense

kenny at m.cs.uiuc.edu kenny at m.cs.uiuc.edu
Thu Nov 17 16:28:00 AEST 1988


/* Written 11:16 am  Nov 15, 1988 by rkl1 at hound.UUCP in m.cs.uiuc.edu:comp.lang.c */
	Well, I suppose that if gets () is capable of overflowing the buffer,
the way to go would be to read the input one character at a time and check
for buffer overflow oneself.  It would be trivial to write a function to do
this, and you only have to do it once and use it from then on instead of gets ()
/* End of text from m.cs.uiuc.edu:comp.lang.c */

How convenient that the deigners of the stardard C library have done
this for us already.  It's called fgets().

Please, can we go to another topic?  I've got one:  do fseek(), fread
(), and fwrite() allow a forward read after a write?  Does it matter
whether it's a text or binary file?

A-T



More information about the Comp.lang.c mailing list