Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <string.h>
size_t strlen(const char *string);
The strlen() built-in function determines the length of string pointed to by string, excluding the terminating NULL character.
strlen() returns the length of 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] ));
}
Output
Input string has a length of 24