size_t
strspn
(
const
char
*s,
const
char
* accept);
STRSPN returns the first word Poute in s that is not present in the accept. Returns An integer value specifying the length of the substring in str This consists entirely of characters in c16> strcharset
. If str begins with a character not in strCharSet
, the function returns 0. accept can contain multiple characters, start a search from STR, and calculate the subscript for any of the characters contained in the Accept in Str.
#include <string.h>#include<stdio.h>Main () {Char*str="Linux is first developed for 386/486-based PCs."; printf ("%d\n", Strspn (str,"Linux")); printf ("%d\n", Strspn (str,"/-")); printf ("%d\n", Strspn (str,"1234567890"));}
Operation Result:
5
0
0
size_t strcspn (const char *s, const char * reject);strcspn () computes successive characters from the beginning of the argument s string, which are not in the string that the parameter reject refers to.simply put, if STRCSPN () returns a value of n, it means that the string s starts with n characters and does not contain characters within the string reject.returns the number of characters in the string reject that are not contained in string s at the beginning.
#include <string.h>Main (void) { Char*str ="Linux is first developed for 386/486-based PCs."; printf ("%d\n", Strcspn (str," ")); printf ("%d\n", Strcspn (str,"/-")); printf ("%d\n", Strcspn (str,"1234567890")); }
Operation Result:
5
33
30
Strspn&strcspn