[Previous]
[Contents]
[Next]

strcspn(), _fstrcspn()

get the number of string characters not from a given set of characters

Synopsis:

#include <string.h>

size_t strcspn( const char *str,
                const char *charset );
size_t _fstrcspn( const char __far *str,
                  const char __far *charset );

Description:

The strcspn() function computes the length of the initial segment of the string pointed to by str that consists entirely of characters not from the string pointed to by charset. The terminating null character is not considered part of str.

The _fstrcspn() function is a data-model-independent form of the strcspn() function that accepts far pointer arguments. It is most useful in mixed memory model applications.

Returns:

The length, in bytes, of the initial segment.

Examples:

#include <stdio.h>
#include <string.h>

void main()
  {
    printf( "%d\n", strcspn( "abcbcadef", "cba" ) );
    printf( "%d\n", strcspn( "xxxbcadef", "cba" ) );
    printf( "%d\n", strcspn( "123456789", "cba" ) );
  }

produces the output:

0
3
9

Classification:

strcspn() is ANSI; _fstrcspn() is WATCOM.
Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

strspn()


[Previous]
[Contents]
[Next]