wmemchr() function in C/C++ Last Updated : 05 Feb, 2021 Comments Improve Suggest changes Like Article Like Report The wmemchr() function in C/C++ Locate character in block of wide characters. This function searches within the first num wide characters of the block pointed by ptr for the first occurrence of ch, and returns a pointer to it. Syntax: const wchar_t* wmemchr( const wchar_t* ptr, wchar_t ch, size_t num ) or wchar_t* wmemchr( wchar_t* ptr, wchar_t ch, size_t num ) Parameters: The function accepts three mandatory parameters which are described below: ptr: specifies the pointer to the character array to be searched for.ch: specifies the character to be located.num: specifies the number of elements of type wchar_t to compare. Return value: The function returns two value as below: On success, it returns a pointer to the location of character array.Otherwise, NULL pointer is returned. Below programs illustrate the above function: Program-1 : C++ // C++ program to illustrate // wmemchr() function #include <bits/stdc++.h> using namespace std; int main() { // initialize the string to be scanned wchar_t ptr[] = L"GeeksForGeeks"; // character to be searched for wchar_t ch = L'o'; // length, till the character to be search for is 8 // run the function to check if the character is present bool look = wmemchr(ptr, ch, 8); if (look) wcout << "'" << ch << "'" << L" is present in first " << 8 << L" characters of \"" << ptr << "\""; else wcout << "'" << ch << "'" << L" is not present in first " << 8 << L" characters of \"" << ptr << "\""; return 0; } Output: 'o' is present in first 8 characters of "GeeksForGeeks" Program 2 : C++ // C++ program to illustrate // wmemchr() function #include <bits/stdc++.h> using namespace std; int main() { // initialize the string to be scanned wchar_t ptr[] = L"GFG"; // character to be searched for wchar_t ch = L'p'; // length, till the character to be search for is 3 // run the function to check if the character is present bool look = wmemchr(ptr, ch, 3); if (look) wcout << "'" << ch << "'" << L" is present in first " << 3 << L" characters of \"" << ptr << "\""; else wcout << "'" << ch << "'" << L" is not present in first " << 3 << L" characters of \"" << ptr << "\""; return 0; } Output: 'p' is not present in first 3 characters of "GFG" Comment More infoAdvertise with us Next Article wmemchr() function in C/C++ A AmanSrivastava1 Follow Improve Article Tags : C++ CPP-Functions C-Library Practice Tags : CPP Similar Reads wmemcpy() function in C/C++ The wmemcpy() function is specified in header file cwchar.h and copies a specified number of character from one string to the other. This function doesn't check for any terminating null wide character in the first string called source it always copies exactly n characters to the second string called 2 min read wmemcmp() function in C/C++ The wmemcmp() function in C/C++ compare two wide characters. This function compares the first num wide characters of two wide characters pointed by str1 and str2, returns zero if both the strings are equal or different value from zero if they are not. Syntax: int wmemcmp (const wchar_t* str1, const 2 min read wcsrchr() function in C/C++ The wcsrchr() function is a builtin function in C/C++ which searches for the last occurrence of a wide character in a wide string. It is defined within the cwchar header file in C++. Syntax: wcsrchr(str, ch) Parameters: The function accepts two parameters which are described below. str: It specifies 2 min read putwchar() function in C/C++ The putwchar() function in C/C++ writes a wide character to stdout (standard output). It is defined in CPP library . Syntax : wint_t putwchar(wchar_t ch) Parameter : The function accepts one mandatory parameter ch which specifies the wide character to be written. Return value : The function returns 2 min read wcschr() function in C++ wcschr() function in C++ searches for the first occurrence of a wide character in a wide string. The terminating null wide character is considered part of the string. Therefore, it can also be located in order to retrieve a pointer to the end of a wide string. Syntax: const wchar_t* wcschr (const wc 2 min read Like