- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library function - strlen()
Description
The C library function size_t strlen(const char *str) computes the length of the string str up to, but not including the terminating null character.
Declaration
Following is the declaration for strlen() function.
size_t strlen(const char *str)
Parameters
str − This is the string whose length is to be found.
Return Value
This function returns the length of string.
Example
The following example shows the usage of strlen() function.
#include <stdio.h> #include <string.h> int main () { char str[50]; int len; strcpy(str, "This is tutorialspoint.com"); len = strlen(str); printf("Length of |%s| is |%d|\n", str, len); return(0); }
Let us compile and run the above program that will produce the following result −
Length of |This is tutorialspoint.com| is |26|
string_h.htm
Advertisements