C examples for string.h:strcspn
function
<cstring> <string.h>
Scans str1 for the first occurrence of any of the characters in str2
size_t strcspn ( 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 part of str1 not containing any of the characters that are part of str2.
#include <stdio.h> #include <string.h> int main ()/*from w ww . j a va2 s .co m*/ { char str[] = "this is a test test73 test test test"; char keys[] = "1234567890"; int i; i = strcspn (str,keys); printf ("The first number in str is at position %d.\n",i+1); return 0; }