X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrchr.c;h=ec296cbce33cab48ae8b9aeaa6fed4500710c83b;hb=ba5eff8dd9b426485e1559b5d6204692d155d9e8;hp=fb169049e22171e7f7fb9200c44fdf3ebbe653ef;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec;p=pdclib diff --git a/functions/string/strchr.c b/functions/string/strchr.c index fb16904..ec296cb 100644 --- a/functions/string/strchr.c +++ b/functions/string/strchr.c @@ -1,17 +1,32 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- +/* $Id$ */ -// ---------------------------------------------------------------------------- -// C++ +/* Release $Name$ */ -const char * strchr( const char * s, int c ) { /* TODO */ }; -char * strchr( char * s, int c ) { /* TODO */ }; +/* strchr( const char *, int ) -// ---------------------------------------------------------------------------- -// Standard C + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ -char * strchr( const char * s, int c ) { /* TODO */ }; +#include + +char * strchr( const char * s, int c ) +{ + do + { + if ( *s == (char) c ) + { + return (char *) s; + } + } while ( *s++ ); + return NULL; +} + +#warning Test driver missing. + +#ifdef TEST +int main() +{ + return 0; +} +#endif