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 the return type of sizeof?
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
Differentiate between full, complete & perfect binary trees.
Discuss the function of conditional operator, size of operator and comma operator with examples.
What is signed and unsigned?
how we can make 3d venturing graphics on outer interface
What is the difference between struct and union in C?
What is difference between constant pointer and constant variable?
write a program to print data of 5 five students with structures?
What are the functions to open and close the file in c language?
What are the applications of c language?
What are loops c?
Who is the founder of c language?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
How can I send mail from within a c program?