strlen function tells the string length

Syntax

C strlen function has the following syntax. size_t strlen(const char *str);

C strlen function is from header file string.h.

Description

C strlen function returns the string length. The null terminator is not counted.

Example

Use C strlen function to get the string length.


#include<string.h>
#include<stdio.h> 
/*w w  w  . j  a  v  a2s. c om*/
int main(void){
   printf("%d", strlen("hello"));
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h