strchr.c (311B)
1 /* 2 * strchr.c - locate character in string 3 * Copyright (C) 2026. All rights reserved. 4 */ 5 6 #include "libc.h" 7 8 char *strchr(const char *s, int c) { 9 char chr = (char)c; 10 11 while (*s != '\0') { 12 if (*s == chr) 13 return (char *)s; 14 s++; 15 } 16 17 if (chr == '\0') 18 return (char *)s; 19 20 return NULL; 21 }