Answers for "strcmp code"

4

strcmp

return
	>0 if first string is large
    <0 if first string is short
     0 if strings are equal
    
int strcmp ( const char * str1, const char * str2 );
Posted by: Guest on May-27-2021
3

strcmp c library

#include <string.h>
Posted by: Guest on April-09-2020
1

strcmp

THINK STRING_1 - STRING_2

strcmp("ab",  "ac");  /* = -1 */
strcmp("abc", "ab");  /* =  1 */
strcmp("abc", "abc"); /* =  0 */
Posted by: Guest on August-06-2021
-1

strcmp code

STRCMP (const char *p1, const char *p2)
{
  const unsigned char *s1 = (const unsigned char *) p1;
  const unsigned char *s2 = (const unsigned char *) p2;
  unsigned char c1, c2;
  do
    {
      c1 = (unsigned char) *s1++;
      c2 = (unsigned char) *s2++;
      if (c1 == '\0')
        return c1 - c2;
    }
  while (c1 == c2);
  return c1 - c2;
}
Posted by: Guest on January-20-2021

Browse Popular Code Answers by Language