Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!husc6!hscfvax!xmjschm From: xmjschm@hscfvax.harvard.edu (MJSchmelzer) Newsgroups: comp.lang.c Subject: Re: Substitute for gets() Message-ID: <722@hscfvax.harvard.edu> Date: 9 Feb 89 00:29:38 GMT References: <721@hscfvax.harvard.edu> Reply-To: xmjschm@hscfvax.UUCP (R00100@MJSchmelzer) Organization: Health Sciences Computing Facility, Harvard University Lines: 20 Thanks to everyone who suggested using fgets() instead of gets(). (There, that was my summary of all the answers mailed to me.) fgets() hadn't even occurred to me because I naively assumed it was like fscanf() and fprint() in that it only differed by adding a stream parameter. Fortunately, fgets() takes 3 parameters, including the all-important buffer-size parameter. Here is the prototype (K&R2, p. 165): char * fgets(char * s, int n, FILE * iop); One final question: No one mentioned scanf("%255s", buffer). This _does_ seem wrong to me, but I can't quite pin it down. Comments? Thanks again! -- ============== xmjschm@harvspha.BITNET ====== There are two kinds of people: Mike Schmelzer xmjschm@hscfvax.harvard.edu They call each other "boring" ============================================== and "weird." -Me