X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrchr.c;h=bff8d054e20ae212c8d5e96064e1b8bbe2a5729d;hp=dcfc025e8cd4bec4ed62e9c548710914b2ae7929;hb=714f97432fcfa2122e21fd3cf184d49a213a180c;hpb=b06bbb1e2a100095da21e18139e4f960604d0d02 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; } -*/