strncmp Function (ROM Call 0x272)

string.h

short strncmp (const unsigned char *s1, const unsigned char *s2, unsigned long maxlen);

Compares at most maxlen characters of one string to another.

strncmp makes the same unsigned comparison as strcmp, but looks at no more than maxlen characters. It starts with the first character in each string and continues with subsequent characters until the corresponding characters differ or until it has examined maxlen characters. strncmp returns an int value based on the result of comparing s1 (or part of it) to s2 (or part of it):

More precisely, if the strings differ, the value of the first nonmatching character in s2 subtracted from the corresponding character in s1 is returned. The subtraction casts the input strings to unsigned chars so that the characters in the range 128..255 are considered above the characters in the range 0..127.

Note: This routine is declared as "short" although the ANSI standard proposes "long". This is important, because TIOS the strncmp routine puts garbage in the higher half of the d0 register.


Used by: TIOS_EV_getAppID


See also: strcmp