Article View: comp.std.c
Article #3708Re: gets() and getchar
From: Lars Wirzenius
Date: Fri, 11 Aug 1995 19:33
Date: Fri, 11 Aug 1995 19:33
21 lines
1569 bytes
1569 bytes
barmar@nic.near.net (Barry Margolin): > While I'm certainly not a fan of gets(), I disagree with your claim that it > shouldn't even be used when both the writer and reader are developed in > conjunction. By your logic, strcpy() also should never be used, because > someone might lengthen the source variable and forget to lengthen the I guess you're right. Hence, according to grand Usenet tradition, I'll have to slightly modify my argument: The crucial distinction between strcpy and gets is that it is _possible_ to check whether the call will succeed before it is made; with gets this is not possible. (Getting the check wrong is similar to getting the length wrong for fgets. This can't be easily fixed; anyone design a language that makes it impossible to make errors?) I'm not that great a fan of strcpy, although I admit I use it frequently. But I didn't write strmaxcpy for nothing. -- Lars.Wirzenius@helsinki.fi (finger wirzeniu@klaava.helsinki.fi)
Technical Details
Message-ID:
<40gbau$kh5@kruuna.helsinki.fi>Path:
arc1-ca.pugleaf.net!news.helsinki.fi!not-for-mailReferences:
<40bqih$bft@caip.rutgers.edu> <1995Aug11.002333.20047@dcs.warwick.ac.uk> <40fn05$686@kruuna.helsinki.fi> <40g2cl$co7@tools.near.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.helsinki.fi!not-for-mail From: wirzeniu@cc.Helsinki.FI (Lars Wirzenius) Newsgroups: comp.std.c Subject: Re: gets() and getchar Date: 11 Aug 1995 22:33:50 +0300 Organization: University of Helsinki Sender: wirzeniu@cc.helsinki.fi Message-ID: <40gbau$kh5@kruuna.helsinki.fi> References: <40bqih$bft@caip.rutgers.edu> <1995Aug11.002333.20047@dcs.warwick.ac.uk> <40fn05$686@kruuna.helsinki.fi> <40g2cl$co7@tools.near.net> NNTP-Posting-Host: kruuna.helsinki.fi Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit