SourcePoint Intel Help

Table of Contents

strcmp

Compare two strings, character by character.

Syntax

[result =] strcmp(string-expr1, string-expr2)

Where:

result

specifies a debug object of type int2 to which the return value is assigned. If result is not specified, the return value is displayed on the next line of the screen.

string-expr1

specifies an nstring variable or a quoted string constant.

string-expr2

specifies an nstring variable or a quoted string constant.

Discussion

The strcmp command compares two ASCII strings, character by character. The comparison stops when a mismatch is found or when a null character is encountered in one of the strings. The return value depends on the difference between the values of the characters at the stopping position. The return value is one of the following:

-1

The final character in string-expr2 is greater than the final character in string-expr1.

0

The final character in string-expr2 is equal to the final character in string-expr1.

1

The final character in string-expr2 is less than the final character in string-expr1.

Example

Command input:

define nstring name1 = "rosenberg"
define nstring name2 = "rosenbaum"
define int4 order = strcmp(name1, name2)
order

Result:

1T

Command input:

strcmp(name2, name1)

Result:

-1T

Related Topics: