Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the usage of pointer in c?

1179


What is wrong in this statement?

1123


What is nested structure?

1026


Why does notstrcat(string, "!");Work?

1120


Explain what will be the outcome of the following conditional statement if the value of variable s is 10?

1232


Define VARIABLE?

1154


Why static variable is used in c?

1017


What are reserved words with a programming language?

1121


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

2055


What language is c written?

1030


Is boolean a datatype in c?

1046


How do you search data in a data file using random access method?

1292


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

1061


How do c compilers work?

1106


What are the two types of functions in c?

987