strlen
find length of string
You're viewing an older version of this page (#4070). View the current version.
INTERFACE
#include <string.h>
size_t strlen ( const char *s )
DESCRIPTION
The strlen function computes the length of the string s.
Example 1
Workings
\code #include <stdio.h> #include <string.h> int main() { char s[20] = "abcde1010101"; printf("The length of \"%s\" is %d characters.
", s, strlen(s)); return 0; } \endcode
Solution
Output:
The length of "abcde1010101" is 12 characters.RETURN VALUES
The strlen function returns the number of characters that precede the terminating NUL character.
STANDARDS
The strlen function conforms to ISO/IEC 9899:1990 ("ISO C90").