在线文档教程
C++
字符串 | Strings

std::wcschr

STD::Wcschr

Defined in header
const wchar_t* wcschr( const wchar_t* str, wchar_t ch
wchar_t* wcschr( wchar_t* str, wchar_t ch

查找宽字符的第一次出现。ch在宽串中,指的是...str...

参数

str-pointer to the null-terminated wide string to be analyzed
ch-wide character to search for

返回值

中找到的字符的指针。str,或NULL如果找不到这样的角色。

二次

#include <iostream> #include <cwchar> #include <locale> int main() { wchar_t arr[] = L"招き猫 кошка"; const wchar_t* cat = std::wcschr(arr, L'猫' const wchar_t* dog = std::wcschr(arr, L'犬' std::cout.imbue(std::locale("en_US.utf8") if(cat) std::cout << "The character 猫 found at position " << cat - arr << '\n'; else std::cout << "The character 猫 not found\n"; if(dog) std::cout << "The character 犬 found at position " << dog - arr << '\n'; else std::cout << "The character 犬 not found\n"; }

二次

产出:

二次

The character 猫 found at position 2 The character 犬 not found

二次

另见

findfind characters in the string (public member function of std::basic_string)
strchrfinds the first occurrence of a character (function)
wcsrchrfinds the last occurrence of a wide character in a wide string (function)
wcspbrkfinds the first location of any wide character in one wide string, in another wide string (function)

c Wcschr文件

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/string/Wide/wcschr