Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Compare Strings
◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
The strcmp, stricmp, strncmp, and strnicmp functions operate
on null-terminated strings. The <string> arguments to these
functions are expected to contain a null character (\0) marking
the end of the string.
The strcmpi and stricmp functions are case-insensitive versions of
strcmp, and the strnicmp function is a case-insensitive version of
strncmp. The strcmpi function is an obsolete synonym for stricmp.
It is supported for compatibility.
The strcmp, strcmpi, and stricmp functions compare <string1> and
<string2> and return a value indicating their relationship, as
follows:
Value Meaning
< 0 <string1> is less than <string2>
= 0 <string1> is identical to <string2>
> 0 <string1> is greater than <string2>
The strncmp and strnicmp functions operate on, at most, the first
<count> characters of null-terminated strings. The strncmp and
strnicmp functions compare, at most, the first <count> characters
of <string1> and <string2> and return a value indicating the
relationship between the substrings, as listed below:
Value Meaning
< 0 <substring1> is less than <substring2>
= 0 <substring1> is identical to <substring2>
> 0 <substring1> is greater than <substring2>
The _f... forms of these functions are model-independent (large-
model) forms that use far pointer forms of the string arguments
and return values. These model-independent functions can be called
from any point in the program. Note that there is not a model-
independent version of the strcmpi function. You should use the
_fstricmp function in its place.
Return Value
The return values for these functions are described above.
-♦-