C examples for string.h:strspn
function
<cstring> <string.h>
Returns the length of the portion of str1 which consists only of characters that are part of str2.
size_t strspn ( const char * str1, const char * str2 );
Parameter | Description |
---|---|
str1 | C string to be scanned. |
str2 | C string containing the characters to match. |
The length of the initial portion of str1 containing only characters that appear in str2.
#include <stdio.h> #include <string.h> int main ()//from www.jav a 2s . c om { int i; char strtext[] = "this is a 0test test 123123123test"; char cset[] = "1234567890"; i = strspn (strtext,cset); printf ("The initial number has %d digits.\n",i); return 0; }