{{keywords>wiki library source code example reference}} ====== strcspn ====== #include //#include /* uncomment this for Windows */ size_t strcspn(const char *str1, const char *str2); === Description === strcspn find the first occurrence of any character in str2 ===== strcspn C Example Code ===== /* * strcspn c example code * http://code-reference.com/c/string.h/strcspn */ #include #include #include /* for strlen */ int main ( void ) { char string[] = "te=st@code-reference.com"; char search_keys[] = "?! ,$%:;&/()="; size_t found; found = strcspn(string,search_keys); if (found > 0 && found < strlen(string)) { printf("is not a e-mail address found incorrect char at position: %i\n", found ); } else { printf("valid e-mail :)\n"); } return 0; } === Output of strcspn example === user@host:~$ ./strcspn is not a e-mail address found incorrect char at position: 2