X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrchr.c;h=bff8d054e20ae212c8d5e96064e1b8bbe2a5729d;hb=fadedcfc3b45653d82210cbd418effc45c46c272;hp=dcfc025e8cd4bec4ed62e9c548710914b2ae7929;hpb=b113d60737b588cd12c349968206c3426c5a1e12;p=pdclib.old diff --git a/functions/string/strchr.c b/functions/string/strchr.c index dcfc025..bff8d05 100644 --- a/functions/string/strchr.c +++ b/functions/string/strchr.c @@ -5,24 +5,17 @@ // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- -// C++ - -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 */ }; +#include <__NULL.h> -/* 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; } -*/