strstr — finds the first insertion of substring.

Description:

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

Returns the pointer to the substring of string string_1 starting from the first insertion of string_2 (including it) and till the end of string string_1.

List of parameters:

string_1

Input string.

string_2

String or pointer to the search string.

Return values:

Returns the pointer to the part of string or 0 if there is no string string_2 in string_1.

Example:

<item addr="524:248" name="Test for strstr function" type="script">
	
V-ID/V-ADDR 
{
	if(opt0())
	{
		u8 str_1[50] = "SmartHouse Smart";
		u8 str_2[50] = "House"; 

		// Example: 1
		u8 *result_1 = strstr(&str_1, &str_2); 

		// Example: 2
		u8 *result_2 = strstr("Larnitech", &str_2);

		// Example: 3
		u8 *result_3 = strstr("Larnitech", "Sm");

		// Example: 4
		u8 *result_4 = strstr(&str_1, "Larni");
		
		// Result output to the interface
		u8 strForMess[100];
		sprintf(strForMess, "%cresult_1: %s\10result_2: %d\10result_3: %s\10result_4: %d", 1, result_1, result_2, result_3,
		result_4);
	
		 setStatus(@exciterId():32, &strForMess);
	}
}
</item>

The result of performing the example in the interface:

result_1: House Larnitech

result_2: 0

result_3: tech

result_3: 0

Note:

strstr function considers the character case.