_mbsspnp, _strspnp, _wcsspnp

unsignedchar*_mbsspnp(constunsignedchar*string1,
**constunsignedchar***string2 );

Routine Required Header Compatibility
_mbsspnp <mbstring.h> Win 95, Win NT
_strspnp <tchar.h> Win 95, Win NT
_wcsspnp <tchar.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

_strspnp, _wcsspnp, and _mbsspnp return a pointer to the first character in string1 that does not belong to the set of characters in string2. Each of these functions returns NULL if string1 consists entirely of characters from string2. For each of these routines, no return value is reserved to indicate an error.

Parameters

string1

Null-terminated string to search

string2

Null-terminated character set

Remarks

The _mbsspnp function returns a pointer to the multibyte character that is the first character in string1 that does not belong to the set of characters in string2. _mbsspnp recognizes multibyte-character sequences according to the multibyte code page currently in use. The search does not include terminating null characters.

The generic-text function _tcsspnp, defined in TCHAR.H, maps to _mbsspnp if _MBCS has been defined, or to _wcsspnp if _UNICODE has been defined. Otherwise _tcsspnp maps to _strspnp. _strspnp and _wcsspnp are single-byte character and wide-character versions of _mbsspnp. _strspnp and _wcsspnp behave identically to _mbsspnp otherwise; they are provided only for this mapping and should not be used for any other reason. For more information, see Using Generic-Text Mappings and Appendix B, Generic-Text Mappings.

Example

/* STRSPN.C: This program uses strspn to determine
 * the length of the segment in the string "cabbage"
 * consisting of a's, b's, and c's. In other words,
 * it finds the first non-abc letter.
 */

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

void main( void )
{
   char string[] = "cabbage";
   int  result;
   result = strspn( string, "abc" );
   printf( "The portion of '%s' containing only a, b, or c "
           "is %d bytes long\n", string, result );
}

Output

The portion of 'cabbage' containing only a, b, or c is 5 bytes long

String Manipulation Routines

See Also   strspn, strcspn, strncat, strncmp, strncpy, _strnicmp, strrchr