find the last occurrence of a character in a string
#include <string.h>
char *strrchr( const char *s, int c );
char __far *_fstrrchr( const char __far *s,
int c );
The strrchr() and _fstrrchr() functions locate 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 _fstrrchr() function is a data-model-independent form of the strrchr() function. It accepts far pointer arguments, and returns a far pointer. It is most useful in mixed memory model applications.
a pointer to the located character, or a NULL pointer if the character does not occur in the string.
#include <stdio.h>
#include <string.h>
void main()
{
printf( "%s\n", strrchr( "abcdeabcde", 'a' ) );
if( strrchr( "abcdeabcde", 'x' ) == NULL )
printf( "NULL\n" );
}
produces the output:
abcde NULL
ANSI