C Program to find length of string without using strlen function


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


int len = strlen( str );


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

Run it Now
#include<stdio.h>

int main() {

   char str[100];
   int len = 0;

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

   while (str[len] != '\0') {
       len++;
   }

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

   return 0;
}

Output:

Enter Any String :Xiith
The Length of String is :5