Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site hadron.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: Need strnlen(). Message-ID: <86@hadron.UUCP> Date: Wed, 20-Nov-85 15:36:57 EST Article-I.D.: hadron.86 Posted: Wed Nov 20 15:36:57 1985 Date-Received: Sat, 23-Nov-85 09:53:27 EST References: <207@a.sei.cmu.edu> <797@dcl-cs.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 26 OK. Let's all stop arguing over whether this routine should exist. #define NUL '\0' /* ** This routine, for whatever reason, wants to calculate the length ** of string 's' but be sure that it stops before element 'n'. */ int strnlen(s, n) register char *s; register int n; { register int i; for (i = 0; i < n; i++) { if (*s++ == NUL) break; } return(i); } There. It exists. If you must use it, do so. I will try not to, but may have to some day. Fair 'nuff? -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}