Back to index

glibc  2.9
Functions
strrchr.c File Reference
#include <string.h>

Go to the source code of this file.

Functions

char * strrchr (const char *s, int c)

Function Documentation

char* strrchr ( const char *  s,
int  c 
)

Definition at line 25 of file strrchr.c.

{
  register const char *found, *p;

  c = (unsigned char) c;

  /* Since strchr is fast, we use it rather than the obvious loop.  */

  if (c == '\0')
    return strchr (s, '\0');

  found = NULL;
  while ((p = strchr (s, c)) != NULL)
    {
      found = p;
      s = p + 1;
    }

  return (char *) found;
}