C++ offers various standard template libraries to be used. One of them is memchr() function which will search for the first occurrence of a character in a specified number of characters.
const void* memchr( const void* ptr, int ch, std::size_t count ); Parameters : ptr : Pointer to the object to be searched for. ch : Character to search for. count : Number of character to be searched for. Return value: If the character is found, the memchr() function returns a pointer to the location of the character, otherwise returns null pointer.
s is present in first 13 characters of "This is a sample"
search character found
This article is contributed by Pranav. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- return statement in C/C++ with Examples
- How to implement our own Vector Class in C++?
- Web Programming in C++
- C++ Program to print an Array using Recursion
- Storage Classes in C++ with Examples
- fill_n() function in C++ STL with examples
- fill() function in C++ STL with examples
- How to erase an element from a vector using erase() and reverse_iterator?
- iomanip setbase() function in C++ with Examples
- iomanip setpricision() function in C++ with Examples
- iomanip setiosflags() function in C++ with Examples
- iomanip setfill() function in C++ with Examples
- Manipulators in C++ with Examples
- iomanip setw() function in C++ with Examples
- iomanip resetiosflags() function in C++ with Examples