commit 3f51e82f5bad60cd837488bd5e1a8badd3441835 parent ff12208b737305ea29849e5ef65abcc37119229a Author: Roberto E. Vargas Caballero <k0ga@shike2.com> Date: Thu, 16 Feb 2017 21:17:30 +0100 [libc] Add strchr() Diffstat:
M | libc/src/Makefile | | | 2 | +- |
A | libc/src/strchr.c | | | 11 | +++++++++++ |
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/libc/src/Makefile b/libc/src/Makefile @@ -1,7 +1,7 @@ # See LICENSE file for copyright and license details. .POSIX: -LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o +LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o all: libc.a diff --git a/libc/src/strchr.c b/libc/src/strchr.c @@ -0,0 +1,11 @@ +/* See LICENSE file for copyright and license details. */ + +#include <string.h> + +char * +strchr(const char *s, int c) +{ + while (*s && *s != c) + ++s; + return (*s) ? (char *) s : NULL; +}