BOOTSTRAP (kutils) functions


LIBRARY ROUTINE

kstrcmp - compare two strings

LIBRARY CALL

int kstrcmp(
   const char *istr1,
   const char *istr2)

INPUT

OUTPUT

none

RETURN VALUE

If the two strings are identical, the value of 0 is returned. If the two strings differ, the ASCII value difference of the first character that differs in the two strings will be returned. If the ASCII value of the differing character in istr1 is greater than the one in istr2, then the return value is positive, and implies that istr1 is greater than istr2. If the difference between the two ASCII values is negative, the return value implies that istr2 is greater than istr1.

DESCRIPTION

This function does a comparison of two strings. It is a replacement for the system strcmp(). It does a character by character case sensitive comparison of both input strings until the current character for one string does not equal the current character of the other string, or until the end of the input strings are reached. It protects against NULL on the input strings by replacing NULL pointers with a reference to an empty string.

ADDITIONAL INFORMATION

none

EXAMPLES

The following example repeats the kstrcasecmp() example.
char *s1 = "John Doe";
char *s2 = "john DOE";
int   result;

result = kstrcmp(s1, s2); kprintf("The result is '%d'\n", result);

The result of this compare is -32 instead of 0, since that is the result of the difference 'J' - 'j'.

SIDE EFFECTS

none

RESTRICTIONS

none

MODIFICATION

none

FILES

$BOOTSTRAP/objects/library/kutils/src/strings.c

SEE ALSO

kutils(3)

COPYRIGHT

Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.