[Previous]
[Contents]
[Next]

strrchr(), _fstrrchr()

find the last occurrence of a character in a string

Synopsis:

#include <string.h>

char *strrchr( const char *s, int c );
char __far *_fstrrchr( const char __far *s, 
                       int c );

Description:

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 _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.

Returns:

A pointer to the located character, or NULL if the character doesn't occur in the string.

Examples:

#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

Classification:

strrchr() is ANSI; _fstrrchr() is WATCOM.

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

strchr(), strpbrk()


[Previous]
[Contents]
[Next]