Strlen() takes a reference to a string and returns the numeric string length up to the NULL or terminating character, but not including the NULL character. - C String

C examples for String:Length

Description

Strlen() takes a reference to a string and returns the numeric string length up to the NULL or terminating character, but not including the NULL character.

Demo Code

#include <stdio.h> 
#include <string.h> 
int main() /*w w  w.jav  a 2 s  .c  o m*/
{ 
   char *str1 = "book2s.com"; 
   char str2[] = "this is a test"; 

   printf("\nThe length of string 1 is %d\n", strlen(str1)); 

   printf("The length of string 2 is %d\n", strlen(str2)); 

}

Result


Related Tutorials