C Program to find 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 length of string using strlen function in c

Run it Now
#include<stdio.h>
#include<string.h>

int main() {

    char str[100];
    int len;

    printf("Enter Any String :");
    fgets(str, 100, stdin);

    len = strlen(str);

    printf("\nThe String Length is :%d", len);

    return 0;
}

Output:

Enter Any String :Xiith
The String Length is :5