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
How #define works?
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.
Explain the advantages and disadvantages of macros.
How can you tell whether two strings are the same?
List some applications of c programming language?
What are the difference between a free-standing and a hosted environment?
How do you generate random numbers in C?
How a string is stored in c?
What are global variables and how do you declare them?
When we use void main and int main?
What are the 5 types of inheritance in c ++?
What is scanf () in c?
What do you understand by friend-functions? How are they used?
Are pointers integers in c?
What does dm mean sexually?