Need strnlen().

preece at ccvaxa.UUCP preece at ccvaxa.UUCP
Fri Nov 22 02:12:00 AEST 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 at 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



More information about the Comp.lang.c mailing list