🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3728

Re: gets() and getchar

#3728
From: Richard Krehbiel
Date: Tue, 15 Aug 1995 12:16
34 lines
1897 bytes
wirzeniu@cc.Helsinki.FI (Lars Wirzenius) wrote:

>Actually, to followup to my own post (darn those quick save-and-post
>fingers), there're a few other mem*/str* functions that might also
>be useful to have in the standard:

>memrchr - counterpart to memchr
>strend - convenience function for strchr(s, '\0')
>strmove - similar to memmove
>strnlen - like strlen, but give a maximum

>strdup is _quite_ common, and should be available in some way.  (After
>that, strndup is nice.)

Are we wishing for new standard library functions?  I have some string
library peeves that new functions would satisfy nicely:

o A version of strncat where you specify the destination string
maximum length.

o A version of strncpy that always delimits the destination.

*Not* *once* have I found the library implementations of these two
functions adequate.  Every time I've used them I've had to augment,
with delimiter-placement code after strncpy, and extra length
calculations with strncat.

I suppose I could use a slightly altered version of strchr, too, that
returns a pointer to the end delimiter on failure, rather than NULL.
But for this I've been getting along fairly well with strcspn.

--
Richard Krehbiel, Kastle Systems, Arlington VA USA
rich@kastle.com (work) or richk@cais.com (personal)
Technical Details
Message-ID: <1995Aug15.121547.11587@friend.kastle.com>
Path: arc1-ca.pugleaf.net!uucp3.netcom.com!friend!news
References: <Pine.ULT.3.91.950807194041.19202A-100000@mars> <40bqih$bft@caip.rutgers.edu> <1995Aug11.002333.20047@dcs.warwick.ac.uk> <40fn05$686@kruuna.helsinki.fi> <40fng8$7ep@kruuna.helsinki.fi>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!uucp3.netcom.com!friend!news
From: rich@kastle.com (Richard Krehbiel)
Subject: Re: gets() and getchar
Message-ID: <1995Aug15.121547.11587@friend.kastle.com>
Sender: news@friend.kastle.com (News)
Reply-To: rich@kastle.com
Organization: Kastle Development Associates
X-Newsreader: Forte Free Agent 1.0.82
References: <Pine.ULT.3.91.950807194041.19202A-100000@mars> <40bqih$bft@caip.rutgers.edu> <1995Aug11.002333.20047@dcs.warwick.ac.uk> <40fn05$686@kruuna.helsinki.fi> <40fng8$7ep@kruuna.helsinki.fi>
Date: Tue, 15 Aug 1995 12:16:10 GMT