C Language and Libraries Help (clang.hlp) (
Table of Contents;
Topic list)
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►
─────Run-Time Library───────────────────────────────────────────────────────
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 _stricmp function is a case-insensitive version 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. These three functions actually
perform a lowercase comparison of their <string> arguments.
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>
Note that for _stricmp, _strnicmp, and _strcmpi, two strings
containing characters located between 'Z' and 'a' in the ASCII
table ('[', '\', ']', '^', '_', and '`') compare differently
depending on their case. For example, the two strings, "ABCDE"
and "ABCD^" compare one way if the comparison is lowercase
("abcde" > "abcd^") and the other way if it is uppercase
("ABCDE" < "ABCD^").
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 memory model. Note that there is not a model-independent
version of the obsolete _strcmpi function. You should use the
_fstricmp function in its place.
Return Value
The return values for these functions are described above.
-♦-