Partager via


strpbrk, wcspbrk (Windows CE 5.0)

Send Feedback

Developing an Application > Microsoft C Run-time Library for Windows CE > Run-time Library Reference

Scan strings for characters in specified character sets.

char *strpbrk( const char *string, const char *strCharSet );wchar_t *wcspbrk( const wchar_t *string, constwchar_t *strCharSet);

Parameters

  • string
    Null-terminated, searched string.
  • strCharSet
    Null-terminated character set.

Return Values

Each of these functions returns a pointer to the first occurrence of any character from strCharSet in string, or a NULL pointer if the two string arguments have no characters in common.

Remarks

These functions are supported by all versions of the C run-time libraries.

The strpbrk function returns a pointer to the first occurrence of a character in string that belongs to the set of characters in strCharSet. The search does not include the terminating null character.

wcspbrk is wide-character version of strpbrk. The arguments and return value of wcspbrk are wide-character strings. These two functions behave identically otherwise.

The following table shows generic-text routine mappings for this function.

TCHAR.H Routine _UNICODE Defined
_tcspbrk wcspbrk

For more information about TCHAR.H routines, see Generic Text Mappings.

Example

Description

The following example finds members of a specified character set.

Code

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

void main( void )
{
   char string[100] = "The 3 men and 2 boys ate 5 pigs\n";
   char *result;
   /* Return pointer to first 'a' or 'b' in "string" */
   printf( "1: %s\n", string );
   result = strpbrk( string, "0123456789" );
   printf( "2: %s\n", result++ );
   result = strpbrk( result, "0123456789" );
   printf( "3: %s\n", result++ );
   result = strpbrk( result, "0123456789" );
   printf( "4: %s\n", result );
}
// Output
1: The 3 men and 2 boys ate 5 pigs

2: 3 men and 2 boys ate 5 pigs

3: 2 boys ate 5 pigs

4: 5 pigs

Requirements

OS Versions: Windows CE 2.0 and later.

Header: stdio.h, string.h.

Link Library: coredll.dll.

See Also

strcspn | strchr | strrchr

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.