C Program to find the length of string using strlen function


In this program, You will learn how to find length of string using strlen function in c.


int len = strlen( str );

Example: How to find the length of string using strlen function in c.

#include<stdio.h>
#include<string.h>

int main() {

    char str[100];
    int len;

    printf("Enter any string:");
    scanf("%[^\n]%*c", str); 


    len = strlen(str);

    printf("String length is:%d", len);

    return 0;
}

Output:

Enter any string:Xiith.com
String length is:9