strlen( ) in C

strlen() function in c counts the number of characters present in a string

Example of strlen() function

main( ) 
{ 
 char arr[ ] = "Bamboozled" ; 
 int len1, len2 ;
en1 = strlen ( arr ) ; 
 len2 = strlen ( "Humpty Dumpty" ) ; 
 printf ( "\nstring = %s length = %d", arr, len1 ) ; 
 printf ( "\nstring = %s length = %d", "Humpty Dumpty", len2 ) ; 
} 

The output would be…

string = Bamboozled length = 10
string = Humpty Dumpty length = 13

Leave a Comment