public static member function
<string>
std::char_traits::findstatic const char_type* find (const char_type* p, size_t n, const char_type& c);
Find first occurrence of character
Returns a pointer to the first character in the sequence of n characters pointed by p that compares equal to c.All character traits types shall implement the function as if the individual characters were compared using member eq.
1
2
3
4
5
6
7
8
9
10
11
// char_traits::find
#include <iostream> // std::cout
#include <string> // std::char_traits
int main ()
{
const char foo[] = "test string";
const char* p = std::char_traits<char>::find(foo,std::char_traits<char>::length(foo),'i');
if (p) std::cout << "the first 'i' in \"" << foo << "\" is at " << (p-foo) << ".\n";
return 0;
}
the first 'i' in "test string" is at 8.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4