Loading...
Select Version
&pagelevel(4)&pagelevel
Definition | #include <string.h> size_t strspn(const char *s1, const char *s2); Starting at the beginning of string s1, As soon as a character in s1 fails to match any character in s2, the function is terminated and the segment length is returned. If the first character in s1 already fails to match any character in s2, the segment length is equal to 0. |
Return val. | Integer value 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]; char *text2 = "0123456789"; size_t n; printf("Example of strspn. Please enter a text line:\n"); scanf("%s", text1); n = strspn(text1, text2); printf("Length of initial segment with digits (0 - 9): %d\n", n); return 0; } |
See also | strcspn |