X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrchr.c;h=960e7e4ed599fd9070b13007969ea5485464831e;hp=dcfc025e8cd4bec4ed62e9c548710914b2ae7929;hb=1d9d92ba957a0b8307c9a65c35867fde68e6533b;hpb=0a5395faab237ba9008352b0f4bee9659bbd3d5f diff --git a/functions/string/strchr.c b/functions/string/strchr.c index dcfc025..960e7e4 100644 --- a/functions/string/strchr.c +++ b/functions/string/strchr.c @@ -1,28 +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 */ }; - -/* PDPC code - unreviewed +char * strchr( const char * src, int c ) { - while (*s != '\0') + while ( *src != '\0' ) { - if (*s == (char)c) return ((char *)s); - s++; + if ( *src == (const char) c ) + { + return (char *) src; + } + ++src; } - return (NULL); + return NULL; } -*/