Edit

Share via


_strspnp, _wcsspnp, _mbsspnp, _mbsspnp_l

Returns a pointer to the first character in a given string that isn't in another given string.

Important

_mbsspnp and _mbsspnp_l cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported in Universal Windows Platform apps.

Syntax

char *_strspnp(
   const char *str,
   const char *charset
);
wchar_t *_wcsspnp(
   const unsigned wchar_t *str,
   const unsigned wchar_t *charset
);
unsigned char *_mbsspnp(
   const unsigned char *str,
   const unsigned char *charset
);
unsigned char *_mbsspnp_l(
   const unsigned char *str,
   const unsigned char *charset,
   _locale_t locale
);

Parameters

str
Null-terminated string to search.

charset
Null-terminated character set.

locale
Locale to use.

Return value

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

Remarks

The _mbsspnp function returns a pointer to the multibyte character that is the first character in str that doesn't belong to the set of characters in charset. _mbsspnp recognizes multibyte-character sequences according to the multibyte code page currently in use. The search doesn't include terminating null characters.

If either str or charset is a null pointer, this function invokes the invalid parameter handler, as described in Parameter validation. If execution is allowed to continue, the function returns NULL and sets errno to EINVAL.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Generic-text routine mappings

Tchar.h routine _UNICODE and _MBCS not defined _MBCS defined _UNICODE defined
_tcsspnp _strspnp _mbsspnp _wcsspnp

_strspnp and _wcsspnp are single-byte character and wide-character versions of _mbsspnp. _strspnp and _wcsspnp behave identically to _mbsspnp otherwise; they're provided only for this mapping and shouldn't be used for any other reason. For more information, see Using generic-text mappings and Generic-text mappings.

_mbsspnp_l is identical except that it uses the locale parameter passed in instead. For more information, see Locale.

Requirements

Routine Required header
_mbsspnp <mbstring.h>
_strspnp <tchar.h>
_wcsspnp <tchar.h>

For more compatibility information, see Compatibility.

Example

// crt_mbsspnp.c
#include <mbstring.h>
#include <stdio.h>

int main( void ) {
   const unsigned char string1[] = "cabbage";
   const unsigned char string2[] = "c";
   unsigned char *ptr = 0;
   ptr = _mbsspnp( string1, string2 );
   printf( "%s\n", ptr);
}

Output

abbage

See also

String manipulation
Locale
Interpretation of multibyte-character sequences
strspn, wcsspn, _mbsspn, _mbsspn_l
strncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_l
strncmp, wcsncmp, _mbsncmp, _mbsncmp_l
strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l
_strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_l
strrchr, wcsrchr, _mbsrchr, _mbsrchr_l