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...

Implement strcmp

Answer Posted / lylez00

#include <string.h>
/* strcmp */
int (strcmp)(const char *s1, const char *s2)
{
unsigned char uc1, uc2;
/* Move s1 and s2 to the first differing characters
in each string, or the ends of the strings if they
are identical. */
while (*s1 != '\0' && *s1 == *s2) {
s1++;
s2++;
}
/* Compare the characters as unsigned char and
return the difference. */
uc1 = (*(unsigned char *) s1);
uc2 = (*(unsigned char *) s2);
return ((uc1 < uc2) ? -1 : (uc1 > uc2));
}

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c++ a good first language to learn?

1060


What is a buffer c++?

1055


What is the v-ptr?

1155


Do you know what are static and dynamic type checking?

1061


What is virtual function? Explain with an example

1091


What are c++ templates used for?

1134


What is this weird colon-member (" : ") syntax in the constructor?

1023


What is ifstream c++?

1028


What are features of c++?

1166


What is #include cstdlib in c++?

1176


What is data types c++?

1012


Explain the uses of static class data?

1096


How the endl and setw manipulator works?

1011


an integer constant must have atleast one a) character b) digit c) decimal point

1020


Does c++ have finally?

1024