X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrrchr.c;h=b29d0a6e26525d236a5d7ec64d963fb2c4e91b3a;hb=ed0101ff5bc5dda85d13eeed5217959bfe87e71c;hp=4249de3b17489863468b9735ac679978d97459e4;hpb=dcc8a8e99f69e090a03b7b868443addbc0817820;p=pdclib.old diff --git a/functions/string/strrchr.c b/functions/string/strrchr.c index 4249de3..b29d0a6 100644 --- a/functions/string/strrchr.c +++ b/functions/string/strrchr.c @@ -1,17 +1,27 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- +/* $Id$ */ -// ---------------------------------------------------------------------------- -// C++ +/* Release $Name$ */ -const char * strrchr( const char * s, int c ) { /* TODO */ }; -char * strrchr( char * s, int c ) { /* TODO */ }; +/* strrchr( const char *, int c ) -// ---------------------------------------------------------------------------- -// Standard C + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ -char * strrchr( const char * s, int c ) { /* TODO */ }; +#include + +char * strrchr( const char * s, int c ) +{ + size_t i = 0; + while ( p[i++] ); + do + { + if ( p[--i] == (char) c ) + { + return (char *) p + i; + } + } while ( i ); + return NULL; +} + +#warning Test driver missing.