Example of C strlen()

The below programs illustrate the strlen() function in C:

C




// c program to demonstrate
// example of strlen() function.
#include <stdio.h>
#include <string.h>
 
int main()
{
    // defining string
    char str[] = "w3wiki";
 
    // getting length of str using strlen()
    int length = strlen(str);
    printf("Length of string is : %d", length);
 
    return 0;
}


Output

Length of string is : 13

strlen() function in c

The strlen() function in C calculates the length of a given string. The strlen() function is defined in string.h header file. It doesn’t count the null character ‘\0’.

Similar Reads

Syntax of C strlen()

The syntax of strlen() function in C is as follows:...

Example of C strlen()

The below programs illustrate the strlen() function in C:...

Important Points about strlen()

...

Contact Us