Loading...
Select Version
&pagelevel(4)&pagelevel
Definition | #include <string.h> size_t strcspn(const char *s1, const char *s2); Starting at the beginning of string s1, As soon as a character in s1 matches a character in s2, the function is terminated and the segment length is returned. If the first character in s1 already matches a character in s2, the segment length is equal to 0. | ||
Return val. | Integer | specifying the segment length (number of non-matching characters) starting from the beginning of string s1. | |
Note | Strings terminated with the null byte (\0) are expected as arguments | ||
Example | #include <stdio.h> #include <string.h> int main(void) { char text1[40]; static char text2[] = "/*#$&"; size_t n; printf("Example of strcspn. Please enter a text line:\n"); scanf("%s",text1); n = strcspn(text1, text2); printf("Length of initial segment without /, *, #, $, &: %d\n", n); return 0; } | ||
See also | strspn |