Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.10 $; site ccvaxa Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ihnp4!inuxc!pur-ee!uiucdcs!ccvaxa!preece From: preece@ccvaxa.UUCP Newsgroups: net.lang.c Subject: Re: Need strnlen(). Message-ID: <2600030@ccvaxa> Date: Thu, 21-Nov-85 11:12:00 EST Article-I.D.: ccvaxa.2600030 Posted: Thu Nov 21 11:12:00 1985 Date-Received: Sat, 23-Nov-85 05:41:11 EST References: <767@dcl-cs.UUCP> Lines: 24 Nf-ID: #R:dcl-cs.UUCP:767:ccvaxa:2600030:000:769 Nf-From: ccvaxa.UUCP!preece Nov 21 10:12:00 1985 > I think that there should be a function called "strnlen" as follows: > > int strnlen (string, size) > char *string; > int size; > > where "size" is the maximum number of bytes in "string". > /* Written 4:14 pm Nov 7, 1985 by stephen@dcl-cs.UUCP > in ccvaxa:net.lang.c */ ---------- This seems perfectly reasonable and useful. Most of the previously posted responses seem pretty obnoxious. On the other hand, where you should have put this is mod.std.c. This is something that belongs in the standard for the string library routines. You might make a proposal for what value you'd like returned if no null character is found before the given limit (-1 and size are reasonable alternatives). -- scott preece gould/csd - urbana ihnp4!uiucdcs!ccvaxa!preece