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

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