Pointer to the null-terminated string to be searched.
2nd Parameter Type : int
Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
2nd Parameter
The character to locate in the string, passed as an `int` but internally converted to `char`.
Read more about parameters of strrchr in parameters section
The strrchrfunction in C language Searches for the last occurrence of the character in the string.
The strrchr function locates the last occurrence of c (converted to a char) in the string pointed to by s. The terminating null character is considered to be part of the string.
The strrchrfunction takes 2
parameters:
•
const char * `str`: Pointer to the null-terminated string to be searched.
•
int `c`: The character to locate in the string, passed as an `int` but internally converted to `char`.
Searches the string `str` for the last occurrence of the character `c`. Returns a pointer to the last occurrence of the character in the string, or `NULL` if the character is not found.
The strrchr function return value :
Returns a pointer to the last occurrence of the character c in the string s, or NULL if the character is not found
Output
This example demonstrates basic usage of strrchr to find the last occurrence of 'o' in a string.