strcmp()

strcmp()

Description

Compare two strings.

Syntax

strcmp(string1[], string2[], ignorecase, length);

Parameters

Variable

Input

Variable

Input

string1[]

The first string in the comparison.

string2[]

The second string in the comparison.

ignorecase

true - case is ignored during the comparison.

false - case is matched during the comparison.

length

The maximum number of characters to consider for comparison in decimal number

Returns

Return value

Return explanation

-1

string1[] less than string2[].

1

string2[] is less than string1[].

0

The strings are equal (for the matched length).

Function call example

Example of string comparing
new data1[10] = ''130''; new data2[10] = ''125''; new data3; main(){ data3 = strcmp(data1, data2, true, sizeof data1); //compare two strings, result will be data3 = 1; while(1){ Delay(1000); } }

Notes and Warnings

Packed and unpacked strings may be mixed in the comparison.

This function does not take the sort order of non-ASCII character sets into account. That is, no Unicode “Collation Algorithm” is used.

Used in Examples

RS232 example

RS485 example

SMS example

Socket example

Socket v2 example

USB example

Bluetooth example