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 are the usage of pointer in c?
What is wrong in this statement?
What is nested structure?
Why does notstrcat(string, "!");Work?
Explain what will be the outcome of the following conditional statement if the value of variable s is 10?
Define VARIABLE?
Why static variable is used in c?
What are reserved words with a programming language?
illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question
What language is c written?
Is boolean a datatype in c?
How do you search data in a data file using random access method?
a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler
How do c compilers work?
What are the two types of functions in c?