write a own function to compare two strings with out using
stringcomparition function?
Answer Posted / ravikiran p sattigeri
/* str_cmp : Comapares the character strings s1 and s2, and
returns negative, zero or positive if s1 is
lexicographically less than, equal to, or greater than s2.
The value is obtained by subtracting the characters at the
first position where s1 and s2 disagree */
/* return < 0 if s1<s2, 0 if s1==s2, >0 if s1>s2 */
int str_cmp (char *s1, char *s2)
{
while(*s1++ == *s2++) {
if (*s1 == '\0')
return 0;
}
return *S1 - *s2;
}
| Is This Answer Correct ? | 13 Yes | 3 No |
Post New Answer View All Answers
what is uses of .net
What does 3 mean in texting?
What are the types of bitwise operator?
Write a program to swap two numbers without using the third variable?
What is the difference between malloc() and calloc() function in c language?
What is wrong with this initialization?
`write a program to display the recomended action depends on a color of trafic light using nested if statments
What is difference between structure and union in c?
What are qualifiers and modifiers c?
What is the function of volatile in c language?
What is the difference between malloc() and calloc()?
Why is structure important for a child?
What are the features of the c language?
Function calling procedures? and their differences? Why should one go for Call by Reference?
What are the advantages of the functions?