Wednesday, 12 October 2016

To find lenght of a string or word without using strlen() function

//to find lenght of a string or word without using strlen() function

#include<stdio.h>

int main()
{
char s[20];
int i,count=0;
printf("enter the string:");
gets(s);
for(i=0;i<20;i++)
{
if(s[i]!='\0')
{
      count++;
    }
else if(s[i]=='\0')
{
break;

}
}
printf("\nThe lenght of the string :%d",count);
}

No comments:

Post a Comment