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
What is the use of gets and puts?
What does == mean in texting?
Explain can the sizeof operator be used to tell the size of an array passed to a function?
What is the difference between constant pointer and constant variable?
Explain what header files do I need in order to define the standard library functions I use?
Explain 'bus error'?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
What does double pointer mean in c?
Compare interpreters and compilers.
What is a shell structure examples?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
What are the different types of C instructions?
Can we replace the struct function in tree syntax with a union?
What is the right type to use for boolean values in c?
Is linux written in c?