.\" Copyright (c) Bruno Haible .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" References consulted: .\" GNU glibc-2 source code and manual .\" .\" Japanese Version Copyright (c) 1999 HANATAKA Shinya .\" all rights reserved. .\" Translated Tue Jan 11 00:55:48 JST 2000 .\" by HANATAKA Shinya .\" .TH STRNLEN 3 2010-10-31 "GNU" "Linux Programmer's Manual" .SH 名前 strnlen \- 固定長の文字列の長さを調べる .SH 書式 .nf .B #include .sp .BI "size_t strnlen(const char *" s ", size_t " maxlen ); .fi .sp .in -4n glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .BR strnlen (): .PD 0 .ad l .RS 4 .TP 4 glibc 2.10 以降: _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L .TP glibc 2.10 より前: _GNU_SOURCE .RE .ad .PD .SH 説明 .BR strnlen () 関数は \fIs\fP が指す文字列の長さをバイト数で返す。 長さには終端の \(aq\\0\(aq 文字を含まない。 また長さは最大で \fImaxlen\fP までであり、 .BR strnlen () は \fIs\fP の最初の \fImaxlen\fP バイトのみを検査し \fIs+maxlen\fP より先を検査することはない。 .SH 返り値 .BR strnlen () 関数は \fImaxlen\fP 以下ならば \fIstrlen(s)\fP と同じ 値を返す。\fIs\fP の指す文字列が最大 \fImaxlen\fP バイトまでに \(aq\\0\(aq 文字を含まない場合には \fImaxlen\fP を返す。 .SH 準拠 この関数は GNU の拡張である。 .SH 関連項目 .BR strlen (3)