Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Smita Kapse

The wcspbrk() function is a built in function of C or C++. It searches for a set of wide characters present in a wide string in another wide string. This function is present into cwhar header file.

This function takes two arguments. The first argument is destination, and the second argument is the source. As destination we have to pass null terminated wide strings to be searched. As source, we have to pass null terminated wide string, that is containing the characters that will be searched.

This function returns two values. If one or more than one wide character is present, this function returns the pointer to the first wide character in destination and also in src. If there is no wide character is present in destination or source, one null pointer is returned.

Example

#include <cwchar>
#include <iostream>
using namespace std;
main () {
   wchar_t wcs[] = L"Hello World. This is C++ PROGRAM.";
   wchar_t key[] = L"aeiouAEIOU";
   wchar_t * pwc;
   wcout << L"Vowels in '"<< wcs << "': ";
   pwc = wcspbrk (wcs, key);
   while (pwc != NULL) {
      wcout << *pwc << L" ";
      pwc = wcspbrk (pwc+1,key);
   }
   wcout << L"\n";
}

Output

Vowels in 'Hello World. This is C++ PROGRAM.': e o o i i O A

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.