strnlen
Section: C Library Functions (3)
Updated: 2026-02-25
Index
JM Home Page
roff page
名前
strnlen - 固定長の文字列の長さを調べる
ライブラリ
標準 C ライブラリ (libc,~-lc)
書式
#include <string.h>
size_t strnlen(const char s[], size_t maxlen);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
strnlen():
Since glibc 2.10:
_POSIX_C_SOURCE >= 200809L
Before glibc 2.10:
_GNU_SOURCE
説明
The strnlen() function returns the number of bytes in the string pointed
to by s, excluding the terminating null byte ('\0'), but at
most maxlen. In doing this, strnlen() looks only at the first
maxlen characters in the string pointed to by s and never beyond
s[maxlen-1].
It is equivalent to
(memchr(s, '\0', maxlen) ?: s + maxlen) - s
返り値
The strnlen() function returns strlen(s), if that is less than
maxlen, or maxlen if there is no null terminating ('\0')
among the first maxlen characters pointed to by s.
属性
この節で使用されている用語の説明については、 attributes(7) を参照。
| インターフェース | 属性 | 値
|
|
strnlen()
| Thread safety | MT-Safe
|
標準規格
POSIX.1-2008.
歴史
POSIX.1-2008.
関連項目
strlen(3)
Index
- 名前
-
- ライブラリ
-
- 書式
-
- 説明
-
- 返り値
-
- 属性
-
- 標準規格
-
- 歴史
-
- 関連項目
-
This document was created by
man2html,
using the manual pages.