strcmp — compares the strings lexicographically.

Description:

u8 strcmp(u8 *string_1, u8 *string_2);

Compares the string string_1 with the string string_2 and returns numeric value.

List of parameters:

string_1

String or pointer to the string.

string_2

String or pointer to the string.

Return values:

· Returns 0 – if string_1 and string_2 are equal.

· Returns the value more than 0 – if string_1 is more than string_2.

· Returns the value less than 0 – if string_1 is less than string_2.

Example:

<item addr="524:248" name="Test for strcmp function" type="script">
	
		V-ID/V-ADDR 
		{
			if(opt0())
			{ 
				i8 cmp_1 = strcmp("hello!", "hello!");
				u8 str_1[] = "abc";
				u8 str_2[] = "aac";
				i8 cmp_2 = strcmp(&str_1, &str_2);
				i8 cmp_3 = strcmp(&str_2, "abc");
				
				// Result output to the interface
				u8 strForMess[50];
				sprintf(strForMess, "%ccmp1 = %d\10cmp2 = %d\10cmp3 = %d", 1, cmp_1, cmp_2, cmp_3);
				setStatus(@exciterId():32, &strForMess);
			}
		}

</item>

The result of performing the example in the interface:

cmp1 = 0

cmp2 = 1

cmp3 = -1

Note:

strcmp function considers the character case.