Format
#include <string.h> size_t strlen(const char *string);
Language Level: ANSI, POSIX, XPG4
strlen determines the length of string excluding the
terminating null character.
Return Value
strlen returns the length of string.
Example
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] ));
return 0;
/***************************************************************
The output should be:
Length of string "How long is this string?" is 24. ***************************************************************/ }
![]()
mblen -- Determine Length of Multibyte
Character
strncat -- Concatenate Strings
strncmp -- Compare Strings
strncpy -- Copy Strings
![]()
strrev -- Reverse String
wcslen -- Calculate Length of
Wide-Character String
<string.h>