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

Explain storage qualifiers in c++.

1131


Why do we use setw in c++?

1165


Write a Program for read a line from file from location N1 to N2 using command line arguments. Eg:exe 10 20 a.c

1332


what is pre-processor in C++?

1215


Which ide is best for c++?

1088


Describe public access specifiers?

1159


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

1070


What are inline functions? What is the syntax for defining an inline function?

1207


What can I use instead of namespace std?

1201


Can comments be nested?

1075


Which function should be used to free the memory allocated by calloc()?

1065


What should main() return in c and c++?

1072


How do you declare A pointer to a function which receives nothing and returns nothing

1298


Which is the best c++ compiler for beginners?

1155


Of the numbers 12 23 9 28 which would be at the top of a properly implemented maxheap a) 28 b) 9 c) Any of them could be

1468