0

Help me to write a c program in recursion method which finds length of string

int strlen(char s[])

My current code:

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

int string_length(char s[]);

main()
{
   char s[50];
   int l;

   printf("Enter the string\n");
   scanf("%s",s);
   l=strlen(s);
   printf("Length of string = %d\n",l);
}

int string_length(char s[])
{
   int i;

   i=0;
   while(s[i] != '\0')
   ++i;
   return i;
}
Michael Myers
  • 188,989
  • 46
  • 291
  • 292
Jashid
  • 9
  • 1
  • 2
  • 7

0 Answers0