X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrchr.c;h=960e7e4ed599fd9070b13007969ea5485464831e;hp=fb169049e22171e7f7fb9200c44fdf3ebbe653ef;hb=1d9d92ba957a0b8307c9a65c35867fde68e6533b;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec diff --git a/functions/string/strchr.c b/functions/string/strchr.c index fb16904..960e7e4 100644 --- a/functions/string/strchr.c +++ b/functions/string/strchr.c @@ -1,17 +1,21 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- + * $Id$ + * ---------------------------------------------------------------------------- + * Public Domain C Library - http://pdclib.sourceforge.net + * This code is Public Domain. Use, modify, and redistribute at will. + * --------------------------------------------------------------------------*/ -// ---------------------------------------------------------------------------- -// C++ +#include <__NULL.h> -const char * strchr( const char * s, int c ) { /* TODO */ }; -char * strchr( char * s, int c ) { /* TODO */ }; - -// ---------------------------------------------------------------------------- -// Standard C - -char * strchr( const char * s, int c ) { /* TODO */ }; +char * strchr( const char * src, int c ) +{ + while ( *src != '\0' ) + { + if ( *src == (const char) c ) + { + return (char *) src; + } + ++src; + } + return NULL; +}