Guardian C Library Calls Reference Manual
Reference to Library Calls
Guardian TNS C Library Calls Reference Manual—128833 3-207
strrchr
strrchr
The strrchr function scans a string backwards for the last occurrence of a given
character.
str_ptr
points to the string to scan.
chr
is the character to scan for.
Return Value
points to the last occurrence in *str_ptr of the character chr. If *str_ptr does not
contain chr, then strrchr returns the pointer value NULL.
Example
This example searches string s for the character “a” and prints the character:
#include <stringh>
#include <stdioh>
int main(void)
{
char *p;
char *s;
int c;
c = 'a';
s = "This is an example";
p = strrchr(s, c);
printf("%c", *p);
}
#include <stringh>
char *strrchr(const char *str_ptr, int chr);