strien ("India is great") function will return_ length of the string
Answers
Answered by
0
Answer:
#include<stdio.h>
int main()
{
char arr[20];
printf("Enter a string:\n");
gets(arr);
int result;
result=strLen(arr);
printf("Length of the string is:%d\n",result);
return 0;
}
int strLen(char *str)
{
char *tmp;
tmp=str;
while(*tmp)
{
tmp++;
}
return (tmp-str);
}
/*
-bash-3.2$ ./a.out
Enter a string:
India
Length of the string is:5
-bash-3.2$ ./a.out
Enter a string:
India is great
Length of the string is:14
*/
Similar questions