Find the first character in one string that is not in another.
#include <string.h> size_t strspn(const char *s1, const char *s2);
s1
A pointer to a character string to search.
s2
A pointer to a list of characters to search for.
This function finds the first character in the character string s1 that is not in the string pointed to by s2. The function starts examining characters at the beginning of s1 and continues searching until a character in s1 does not match any character in s2. Both s1 and s2 must point to null-terminated character arrays.
The function returns the index of the first character in s1 that does not match a character in s2.
This facility may not be available on some configurations of the EWL.
#include <string.h> #include <stdio.h> int main(void) { char s1[] = "create *build* construct"; char s2[] = "create *"; printf(" s1 = %s\n s2 = %s\n", s1, s2); printf(" %d\n", strspn(s1, s2)); return 0; } Output: s1 = create *build* construct s2 = create * 8