I have forgotten
my Password

Or login with:

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

strcspn

Span the complement of a string
+ View other versions (3)

Interface

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

Description

The strcspn function spans the initial part of the null-terminated string s as long as the characters from s do not occur in string charset (it spans the complement of charset).

Example:

Example - Span the complement of a string
Workings
#include <stdio.h>
#include <string.h>
int main()
{
  char s[20] = "abcde1010101", t[3] = "01";
  printf("The first binary digit of s is at position: %d.\n", strcspn(s, t));
  return 0;
}
Solution
Output:
The first binary digit of s is at position: 5.

Return Values

The strcspn function returns the number of characters spanned.

Standards

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