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 email@example.com. 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.
- Find the Deepest Node in a Binary Tree Using Queue STL - SET 2
- C++ program to compare two Strings using Operator Overloading
- not1 and not2 function templates in C++ STL with Examples
- Go vs C++
- Trie Data Structure using smart pointer and OOP in C++
- Modular Exponentiation of Complex Numbers
- std::hash class in C++ STL
- History of C++
- What are Forward declarations in C++
- __builtin_inf() functions of GCC compiler
- Structures in C++
- Variables in C++
- Implementing Forward Iterator in BST
- Count substrings that contain all vowels | SET 2
- Machine Learning in C++