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 program to compare two strings without using the
strcmp() function

Answer Posted / sujith

I have been seeing lot of answers posted on top of mine.
here is another highly optimized version.

int str_cmp (const char *s1, const char *s2)
{
while (*s1 == *s2++)
if (*s1++ == 0)
return (0);
return (*(unsigned char *)s1 - *(unsigned char *)--s2);
}
before marking it as not an answer, I urge you to try it once!
Trust me, it works.

Is This Answer Correct ?    6 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How #define works?

1072


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

2800


Explain the advantages and disadvantages of macros.

1054


How can you tell whether two strings are the same?

1224


List some applications of c programming language?

928


What are the difference between a free-standing and a hosted environment?

1255


How do you generate random numbers in C?

1164


How a string is stored in c?

1033


What are global variables and how do you declare them?

1042


When we use void main and int main?

1043


What are the 5 types of inheritance in c ++?

993


What is scanf () in c?

1092


What do you understand by friend-functions? How are they used?

1178


Are pointers integers in c?

1044


What does dm mean sexually?

1278