Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!hplabs!sm.unisys.com!cs.utexas.edu!rutgers!att!oucsace!pmech From: pmech@oucsace.cs.OHIOU.EDU (Paul J. Mech) Newsgroups: comp.lang.c Subject: Re: gets(3) nonsense Message-ID: <358@oucsace.cs.OHIOU.EDU> Date: 17 Nov 88 09:27:47 GMT References: <867@cernvax.UUCP> <645@quintus.UUCP> <339@igor.Rational.COM> <2747@hound.UUCP> Organization: Ohio University CS Dept., Athens Lines: 21 In article <2747@hound.UUCP>, rkl1@hound.UUCP (K.LAUX) writes: > > 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 () > > --rkl Agreed, it was one of the first functions I wrote (I called mine getln()). I just don't see why some people are damning gets(). I still use gets() whenever I am writing a quick and dirty program that I will swiftly (read immediately) discard after use, or for some aid that only I will have access to with all the data being known not to cause an overflow. If a customer is to get within spitting distance of it, or if I pass it on to another programmer, I use getln(), and include the (rather trivial) source. Despite what seems to be the hysteria of the moment, gets() is useful. But like most things associated with 'C', you have to be careful how you use it. pjm