strcspn
size_t  strcspn ( const char * string1, const char * string2 );
string.h
  cplusplus.com  

Search string for occurrence of character set.
  Scans string1 character by character, returning the number of characters read until the first occurrence of any character included in string2.
  The search includes terminating null-characters, so the function will return the length of string1 if none of the characters included in string2 is in string1.

Parameters.

string1
Null-terminated string to be scanned.
string2
Null-terminated string containing the character set to search for.

Return Value.
  Returns the position in string1 of the first occurence of a component character of string2.

Portability.
  Defined in ANSI-C.

Example.

/* strcspn example */
#include <stdio.h>
#include <string.h>

main ()
{
  char str1[] = "fcba73";
  char str2[] = "1234567890";
  int i;
  i = strcspn (str1,str2);
  printf ("The first number in str1 is str1[%d]\n",i);
  return 0;
}
Output:
The first number in str1 is str1[4]

See also.
  strspn, strstr, strncmp


© The C++ Resources Network, 2000