strspn - C string.h

C examples for string.h:strspn

Type

function

From

<cstring> 
<string.h>

Description

Returns the length of the portion of str1 which consists only of characters that are part of str2.

Prototype

size_t strspn ( const char * str1, const char * str2 );

Parameters

Parameter Description
str1 C string to be scanned.
str2 C string containing the characters to match.

Return value

The length of the initial portion of str1 containing only characters that appear in str2.

Demo Code


#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;
}

Related Tutorials