summaryrefslogtreecommitdiff
path: root/lib/libc/string/strchr.c
blob: 09b4d431ee59f8d526fa16a3c41bec0492c1a347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <string.h>

char *strchr(const char *s, int c) {
	do {
		if ((char)c == *s) {
			return (char*)s;
		}
	} while (*s++ != '\0');
	return NULL;
}

char *strrchr(const char *s, int c)
{
	const char *last = NULL;
	do {
		if (*s == (char)c)
			last = s;
	} while (*s++);
	return (char *)last;
}