strrchr

Locates the last occurrence of a specified character in a string

Local Servers:nonblocking
Remote Servers:N/A
Classification:ANSI
Service:String Manipulation

Syntax

  #include <string.h>  
   
  char *strrchr  (  
     const char   *s,   
     int           c);
  

Parameters

s
(IN) Points to the string containing characters to be searched.
c
(IN) Specifies the character to locate.

Return Values

The strrchr function returns a pointer to the located character or a NULL pointer if the character does not occur in the string.

Remarks

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.

See Also

strchr, strpbrk

Example

  #include <stdio.h>  
  #include <string.h>  
   
  main ()  
  {  
     printf ("%s\n", strrchr ("abcdeabcde", ’a’) );  
     if (strrchr ("abcdeabcde",`x’) == NULL)  
        printf ("NULL\n");  
  }
  

produces the following:

  abcde  
  NULL