From 714f97432fcfa2122e21fd3cf184d49a213a180c Mon Sep 17 00:00:00 2001 From: solar Date: Sun, 18 Jan 2004 15:59:07 +0000 Subject: [PATCH] Reviewed. --- functions/string/strchr.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) 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; } -*/ -- 2.40.0