function
<cstring>
strcspnsize_t strcspn ( const char * str1, const char * str2 );
Get span until character in string
Scans str1 for the first occurrence of any of the characters that are part of str2, returning the number of characters of str1 read before this first occurrence.The search includes the terminating null-characters. Therefore, the function will return the length of str1 if none of the characters of str2 are found in str1.
1
2
3
4
5
6
7
8
9
10
11
12
13
/* strcspn example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] = "fcba73";
char keys[] = "1234567890";
int i;
i = strcspn (str,keys);
printf ("The first number in str is at position %d.\n",i+1);
return 0;
}
The first number in str is at position 5
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4