strrchr
locate character in string
You're viewing an older version of this page (#3512). View the current version.
INTERFACE
#include <string.h> char strrchr ( const char *s, int c )
DESCRIPTION
The strrchr function locates the last occurrence of c (converted to a char) in the string s. If c is '<span class="Qlq">\\0</span>', strrchr locates the terminating '<span class="Qlq">\\0</span>'.
Example 1
#include <stdio.h>
#include <string.h>
int main()
{
char s[20] = "01234560789";
printf("The last position of '0' is %d.\n", strrchr(s, '0') - s);
return 0;
}Output:
The last position of '0' is 7.RETURN VALUES
The strrchr function returns a pointer to the character, or a null pointer if c does not occur anywhere in s.
SEE ALSO
memchr, strchr, strcspn, strpbrk, strspn, strstr, strtok
STANDARDS
The strrchr function conforms to ISO/IEC 9899:1990 ("ISO C90").