strrchr
| String Manipulation Functions |
Finds the last occurrence of a character in a string.
char *strrchr( const char *string, int c );
| string | The string that is searched. |
| c | The character that is searched for in the string. |
Return Values
Returns a pointer to the first occurrence of string2 in string1. If string2 is not found in string1 the function returns NULL.
Example
The following example uses strrchr to find the last instance of the character `x' in the string, string.
#include <string.h>
char * string = "His Excellency the Duke of Exeter";
char * first_x, * last_x;
first_x = (char *)strchr(string, 'x');
lr_output_message ("The first occurrence of x: %s", first_x);
last_x = (char *)strrchr(string, 'x');
lr_output_message ("The last occurrence of x: %s", last_x);Example: Output:
Action.c(7): The first occurrence of x: xcellency the Duke of Exeter
Action.c(10): The last occurrence of x: xeter

