Name
strnlen - determine the length of a fixed-size string
Library
libc.lib
Synopsis
|
size_t
strlen (const char *s, size_t maxlen);
|
Return values
The
strnlen
function returns strlen(s), if that is less than maxlen, or
maxlen if there is no "\0" character among the first maxlen characters
pointed to by s.
Detailed description
The
strnlen
function returns the number of characters in the string
pointed to by s, not including the terminating "\0" character, but at
most maxlen. In doing this, strnlen looks only at the first maxlen
characters at s and never beyond s+maxlen.
s.
Examples
#include <string.h>
#include <stdio.h>
int main()
{
char one[50];
int ret;
strcpy(one,"abcdef");
ret = strnlen(one,5);
printf("Length obtained using strnlen = %d\n",ret);
ret = strnlen(one,10);
printf("Length obtained using strnlen = %d\n",ret);
}
Output
Length obtained using strnlen = 5
Length obtained using strnlen = 6
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|