strcmp()
Description
Compare two strings.
Syntax
strcmp(string1[], string2[], ignorecase, length);
Parameters
Variable | Input |
|---|---|
| The first string in the comparison. |
| The second string in the comparison. |
| true - case is ignored during the comparison. false - case is matched during the comparison. |
| The maximum number of characters to consider for comparison in decimal number |
Returns
Return value | Return explanation |
-1 |
|
1 |
|
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.