1) edit the directory of this segment in strcat
Char * strcat (char * To, const char * From );
Function:Link two strings.
Example:
In this example, use the strcat link string cheers_lee and @ hotmail.com.
The script is as follows:
Char test [1024], * A = "@ hotmail.com ";
Strcpy (test, "cheers_lee ");
Strcat (test, );
Lr_output_message ("we can see % s", test );
Run the following statement in executon log:
Starting action.
Action. C (16): We can see Cheers_Lee@hotmail.com
2) edit the Back-to-directory char * strchr (const char * string, int C) in strchr );
Function:Returns the string after the specified character in the string.
Example:
In this example, all characters after the first occurrence of the E character and after the last occurrence of the E character are returned.
The script is as follows:
Char * string = "cheers is a tester ";
Char * first_e, * last_e;
First_e = (char *) strchr (string, 'E ');
Lr_output_message ("we can see the first occurrence of E: % s", first_e );
Last_e = (char *) strrchr (string, 'E ');
Lr_output_message ("we can see the last occurrence of E: % s", last_e );
Run the following statement in executon log:
Starting action.
Action. C (12): we can see the first occurrence of E: eers is a tester
Action. C (14): we can see the last occurrence of E: Er 3) edit this segment back to directory strcmp & stricmp
Int strcmp (const char * string1, const char * string2); case sensitive.
Int stricmp (const char * string1, const char * string2); case insensitive.
Function:Compare strings.
Example:
Compare the two strings by Case sensitivity and print their size relationships.
The script is as follows:
Int result;
Char TMP [20];
Char string1 [] = "we can see the string: Cheers ";
Char string2 [] = "we can see the string: Cheers ";
Result = strcmp (string1, string2 );
If (result> 0)
Strcpy (TMP, "greater ");
Else if (result <0)
Strcpy (TMP, "less ");
Else
Strcpy (TMP, "equal ");
Lr_output_message ("strcmp: String 1% s string 2", TMP );
Result = stricmp (string1, string2 );
If (result> 0)
Strcpy (TMP, "greater ");
Else if (result <0)
Strcpy (TMP, "less ");
Else
Strcpy (TMP, "equal ");
Lr_output_message ("stricmp: String 1% s string 2", TMP );
Run the following statement in executon log:
Starting action.
Action. C (22): strcmp: String 1 less than string 2
Action. C (33): stricmp: String 1 equals string 2
4) strcpy edit the Back-to-directory char * strcpy (char * DEST, const char * Source );
Function:Copy a string to another string.
Example:
Copy a string to the character array and print it out.
The script is as follows:
Char test [1024];
Strcpy (test, "What can we see? ");
Lr_output_message ("% s", test );
Run the following statement in executon log:
Starting action.
Action. C (10): What can we see? 5) edit the Back-to-directory char * strdup (const char * string) in strdup & strlwr );
Function:Copy a string.
Char * strlwr (char * string );
Function:To lowercase letters.
Example:
In this example, the vuser group name is converted to lowercase letters. However, lr_whoami returns the group name as a static buffer. Such a buffer cannot be operated. If any operation is required, copy the static buffer.
The script is as follows:
Int ID;
Char * groupname_static, * groupname;
Lr_whoami (& ID, & groupname_static, null );
Lr_output_message ("groupname = % s", groupname_static );
Groupname = (char *) strdup (groupname_static );
Groupname = (char *) strlwr (groupname );
Lr_output_message ("lower case groupname = % s", groupname );
Free (groupname );
The above script is saved as: change with vugen
Run in controller (set to always send messages)
After running, the following statement is displayed in log:
Starting action. [msgid: MMSG-15919]
Action. C (11): groupname = change [msgid: MMSG-17999]
Action. C (16): lower case groupname = change [msgid: MMSG-17999] 6) strlen edit this paragraph back directory size_t strlen (const char * string );
Function:Returns the string length (bytes ).
Example:
In this example, we can obtain the number of characters in a string. Then print it out.
The script is as follows:
Starting action. [msgid: MMSG-15919]
Action. C (11): groupname = change [msgid: MMSG-17999]
Action. C (16): lower case groupname = change [msgid: MMSG-17999]
After running, the following statement is displayed in log:
Action. C (13): the sentence has 18 letters
7) EDIT strncat's back-to-directory char * strncat (char * to_string, const char * from_string, size_t N );
Function:Connect a string to the end of another string.
Example:
Here, I casually wrote two strings, used this function to connect them and print them out.
The script is as follows:
Char str1 [] = "cheers is ";
Char str2 [] = "a tester .";
Lr_output_message ("What can we see? ");
Lr_output_message ("The str1 is % S.", str1 );
Strncat (str1, str2, 20 );
Lr_output_message ("The str1 is % S.", str1 );
After running, the following statement is displayed in log:
Action. C (9): What can we see?
Action. C (10): The str1 is cheers is.
Action. C (13): The str1 is cheers is a tester ..
Note: The str1 before the connection is cheers is, and the connected string is Zee is a tester. You can also look at the strcat function.
8) edit this segment of back-to-directory int strncmp (const char * string1, const char * string2, size_t N );
Function:Compare the first n digits of the two strings.
Example:
Compare two strings and print the comparison results. Here I will write it with the strcmp above.
The script is as follows:
Char result;
Char str1 [] = "cheers is a tester .";
Char str2 [] = "cheers is a tester .";
Char str3 [] = "cheers is a tester? ";
Result = strcmp (str1, str2 );
If (result> 0)
Lr_output_message ("str1 is greater than str2 .");
Else if (result <0)
Lr_output_message ("str1 is less than str2 .");
Else
Lr_output_message ("str1 is equal to str2 .");
Result = strncmp (str1, str3, 30 );
If (result> 0)
Lr_output_message ("str1 is greater than str3 .");
Else if (result <0)
Lr_output_message ("str1 is less than str3 .");
Else
Lr_output_message ("str1 is equal to str3 .");
After running, the following statement is displayed in log:
Starting iteration 1.
Starting action.
Action. C (18): str1 is equal to str2.
Action. C (28): str1 is less than str3.