summaryrefslogtreecommitdiff
path: root/lib/libc/string/strspn.c
blob: 3b7036cc93fbae4ef9f10f358e055cd81d0c691a (plain)
1
2
3
4
5
6
7
8
9
10
11
#include <string.h> // for size_t, strchr, strspn, NULL

size_t strspn(const char *s1, const char *s2)
{
	size_t count = 0;
	while (*s1 != '\0' && strchr(s2, *s1) != NULL) {
		count++;
		s1++;
	}
	return count;
}