strrchr(3) CLIX strrchr(3)
NAME
strrchr - Locates last occurence of a specified character in a string
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <string.h>
char *strrchr(
char * string ,
int character );
PARAMETERS
string A pointer to a character string
character
A character
DESCRIPTION
The strrchr() function returns a pointer to the last occurrence of the
value specified by the character parameter in the string pointed to by the
string parameter, or a NULL pointer if the character does not occur in the
string. The terminating null character is treated as a part of the string
pointed to by the string parameter.
EXAMPLES
#include <stdio.h>
#include <string.h>
main()
{
int comma;
char *string;
char *comma_ptr;
string = "abc, def, hello";
comma = (int)`,';
/* This call will return a pointer to the last comma in `string' */
comma_ptr = strrchr(string, comma);
if (! comma_ptr)
printf("There is no comma in the string %s\n", string);
else
2/94 - Intergraph Corporation 1
strrchr(3) CLIX strrchr(3)
printf("The substring which begins with the last comma is %s\n",
comma_ptr);
}
RETURN VALUES
The strrchr() function returns a pointer to the last occurrence of the
value specified by the character parameter, or a NULL pointer if the
character does not occur in the string.
RELATED INFORMATION
Functions: index(3), rindex(3), strcat(3), strcmp(3), strcspn(3),
strchr(3), strcpy(3), strlen(3), strncat(3), strncmp(3), strncpy(3),
strpbrk(3), strspn(3)
2 Intergraph Corporation - 2/94