I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
ComputingCString.h

strspn

Span a string
+ View other versions (4)

Interface

#include <string.h>
size_t strspn (const char *s, const char *charset)

Description

The strspn function spans the initial part of the null-terminated string \c s as long as the characters from \c s occur in string \c charset.

Example:
Example - Span a string
Workings
#include <stdio.h>
#include <string.h>
int main()
{
  char s[20] = "0123456abcde", t[11] = "0123456789";
  printf("The position of the first non-digit in s is: %d.\n", strspn(s, t));
  return 0;
}
Solution
Output:
The position of the first non-digit in s is: 7.

Return Values

The strspn function returns the number of characters spanned.

Standards

The strspn function conforms to ISO/IEC 9899:1990 ("ISO C90").