X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Gergo Barany Newsgroups: comp.lang.c,comp.os.msdos.djgpp,comp.lang.c++ Subject: Re: String substitution to another Followup-To: comp.lang.c Date: 10 Dec 2001 15:47:45 GMT Organization: Vienna University of Technology, Austria Lines: 22 Message-ID: References: <3C151123 DOT D1E94FE8 AT surfeu DOT fi> <3c149894 DOT 7181858 AT news DOT tiscali DOT nl> <9v2knf$htt$0 AT 216 DOT 39 DOT 135 DOT 9> NNTP-Posting-Host: tk150072.tuwien.teleweb.at User-Agent: slrn/0.9.7.3 (Linux) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com [Followups to comp.lang.c only] Aaron Evans wrote: > how is > > gets(filename) || length > MAXLINELENGTH > > more dangerous than > > fgets (strline, MAXLINELENGTH, fileptr); The first version never works correctly if the user can enter more characters than the string filename can hold. (And you usually have no control over the input from the user.) The second can work if MAXLENGTH's value is appropriate (i.e. not more than the length of strline). Gergo -- To whom it may concern: My e-mail address has changed. Please adjust your killfiles and address books. Thanks.