標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
ISO C |
両方 |
#include <string.h>
size_t strlen(const char *string);
strlen() 組み込み関数によって、終了 NULL 文字を除く 、string で示されるストリングの長さが判別されます。
strlen() は、string の長さを戻します。
⁄* CELEBS43
This example determines the length of the string that is
passed to main.
*⁄
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
if ( argc != 2 )
printf( "Usage: %s string¥n", argv[0] );
else
printf( "Input string has a length of %i¥n", strlen( argv[1] ));
}
出力
Input string has a length of 24