1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
8 .\" References consulted:
9 .\" GNU glibc-2 source code and manual
11 .TH STRNLEN 3 1999-07-25 "GNU" "Linux Programmer's Manual"
13 strnlen \- determine the length of a fixed-size string
16 .B #define _GNU_SOURCE
18 .B #include <string.h>
20 .BI "size_t strnlen(const char *" s ", size_t " maxlen );
23 The \fBstrnlen\fP() function returns the number of characters in the string
24 pointed to by \fIs\fP, not including the terminating '\\0' character, but
25 at most \fImaxlen\fP. In doing this, \fBstrnlen\fP() looks only at the first
26 \fImaxlen\fP characters at \fIs\fP and never beyond \fIs+maxlen\fP.
28 The \fBstrnlen\fP() function returns \fIstrlen(s)\fP, if that is less than
29 \fImaxlen\fP, or \fImaxlen\fP if there is no '\\0' character among the first
30 \fImaxlen\fP characters pointed to by \fIs\fP.
32 This function is a GNU extension.