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

Is fortran still used in 2018?

1043


What is a void pointer? When is a void pointer used?

1065


Explain what is page thrashing?

1105


Ow can I insert or delete a line (or record) in the middle of a file?

1005


Discuss the function of conditional operator, size of operator and comma operator with examples.

1166


What is the use of in c?

1034


What is the difference between union and structure in c?

1186


c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above

1269


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

3155


Is it possible to use curly brackets ({}) to enclose single line code in c program?

1325


Why is c not oop?

982


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

1179


what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)

2415


When can you use a pointer with a function?

1080


How can I remove the leading spaces from a string?

1172