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 );
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 );
strcmp
THINK STRING_1 - STRING_2
strcmp("ab", "ac"); /* = -1 */
strcmp("abc", "ab"); /* = 1 */
strcmp("abc", "abc"); /* = 0 */
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;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us