strcspn
span the complement of a string
You're viewing an older version of this page (#4065). View the current version.
INTERFACE
#include <string.h>
size_t strcspn ( const char *s, const char *charset )
DESCRIPTION
The strcspn function spans the initial part of the null-terminated string s as long as the characters from s do not occur in string charset (it spans the complement of charset).
Example 1
Workings
\code #include <stdio.h> #include <string.h> int main() { char s[20] = "abcde1010101", t[3] = "01"; printf("The first binary digit of s is at position: %d.
", strcspn(s, t)); return 0; } \endcode
Solution
Output:
The first binary digit of s is at position: 5.RETURN VALUES
The strcspn function returns the number of characters spanned.
SEE ALSO
memchr, strchr, strpbrk, strrchr, strspn, strstr, strtok
STANDARDS
The strcspn function conforms to ISO/IEC 9899:1990 ("ISO C90").