| |||
| Home > RealView Debugger Predefined Macros > Alphabetical predefined macro reference > strcmp | |||
Compares two strings.
unsigned long strcmp (str1, str2) char *str1; char *str2;
where:
str1Variable of type pointer to char. Specifies the location in memory of the first byte of a character string.
str2Variable of type pointer to char. Specifies the location in memory of the first byte of a character string.
This macro compares two strings based on the internal machine representation of the characters.
For example, ASCII A has the value 41 in hexadecimal notation and ASCII B has the value 42 in hexadecimal notation. Therefore, A is less than B.
This macro behaves like the strcmp function
in the ANSI C string library.
intOne of the following:
-1Indicates that the second argument string value
comes after the first argument string value in the machine collating
sequences, str1 < str2.
0Indicates that the two strings are identical in content.
1Indicates
that the first argument string value comes after the second argument
string value in the machine collating sequences, str2 < str1.
Strings
are assumed to be NUL terminated or to fit within
the array boundaries.
Comparisons are always signed, regardless of how the string is declared.
This example shows how to use strcmp on
the command line:
ce strcmp(“string1”,”string2”) Result is: -1 0xFFFFFFFFFFFFFFFF