how to generate the length of a string without using len
funtion?

Answer Posted / poornima

#include<stdio.h>
int strlength(char *);
int main()
{
char *str;
int len;
printf("Enter a string : ");
gets(str);
len=strlength(str);
printf("Length of %s is %d",str,len);
return 0;
}
int strlength(char *str)
{
int len=0;
for(;*str!='\0';str++)
{
len++;
}
return len;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is function prototype in c with example?

584


What does %d do?

733


What is memory leak in c?

640


Why is c still so popular?

623


What is dynamic memory allocation?

817






What is the value of h?

599


What is the purpose of void in c?

626


What is a substring in c?

599


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

4514


i want to know the procedure of qualcomm for getting a job through offcampus

1949


Explain the use of fflush() function?

631


Why do some versions of toupper act strangely if given an upper-case letter?

641


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

586


What is time complexity c?

575


What is function pointer c?

593