C Programming - Strings - Discussion
Discussion Forum : Strings - General Questions (Q.No. 7)
7.
Which of the following function is correct that finds the length of a string?
Answer: Option
Explanation:
Option A is the correct function to find the length of given string.
Example:
#include<stdio.h>
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
{ length++; s++; }
return (length);
}
int main()
{
char d[] = "IndiaBIX";
printf("Length = %d\n", xstrlen(d));
return 0;
}
Output: Length = 8
Discussion:
17 comments Page 2 of 2.
Devi achsah said:
8 years ago
I don't know exactly. But I can share I what know. In this program xstrlen is only the name of the function.
Marcos said:
8 years ago
What exactly xstrlen() do than strlen()? Explain.
Vivek ladhe said:
6 years ago
@Akshay.
strlen is a std library function.
xstrlen is a user-defined function.
strlen is a std library function.
xstrlen is a user-defined function.
Abay said:
6 years ago
what do strleni(); do? Please explain.
Ahmed Shindy said:
3 years ago
"IndiaBix" length is 9 including the null termination character.
Am I right? Anyone, please clarify.
Am I right? Anyone, please clarify.
(1)
Harsh said:
3 years ago
@Ahmed;
Strlen gives output of string length excluding null character.
Strlen gives output of string length excluding null character.
Shendu said:
1 year ago
It's a very good website for gathering the knowledge.
Also, it is helpful for the placement. Thanks all.
Also, it is helpful for the placement. Thanks all.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers