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

What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

1538


Is c procedural or object oriented?

1084


What is use of integral promotions in c?

1206


Why we use stdio h in c?

1092


What is the difference between c &c++?

1205


c language interview questions & answer

2013


What is the total generic pointer type?

1208


please send me the code for multiplying sparse matrix using c

2220


What happens if header file is included twice?

1211


a program that can input number of records and can view it again the record

1959


What is omp_num_threads?

1132


What is openmp in c?

1064


What is malloc return c?

1078


How to find a missed value, if you want to store 100 values in a 99 sized array?

1461


What is the use of header?

1139