Namespaces
Variants

std:: wcsstr

From cppreference.net
헤더 파일에 정의됨 <cwchar>
const wchar_t * wcsstr ( const wchar_t * dest, const wchar_t * src ) ;
wchar_t * wcsstr ( wchar_t * dest, const wchar_t * src ) ;

와이드 문자열 src 가 가리키는 와이드 문자열에서 첫 번째로 나타나는 dest 를 찾습니다. 종료 널 문자는 비교되지 않습니다.

목차

매개변수

dest - 검사할 null 종료 와이드 문자열에 대한 포인터
src - 검색할 null 종료 와이드 문자열에 대한 포인터

반환값

찾은 부분 문자열의 첫 번째 문자를 가리키는 포인터를 반환하며, dest 에 해당 부분 문자열이 없으면 null 포인터를 반환합니다. 만약 src 가 빈 문자열을 가리키는 경우, dest 가 반환됩니다.

예제

#include <clocale>
#include <cwchar>
#include <iostream>
int main()
{
    wchar_t const* origin = L"アルファ, ベータ, ガンマ, アルファ, ベータ, ガンマ.";
    wchar_t const* target = L"ベータ";
    wchar_t const* result = origin;
    std::setlocale(LC_ALL, "en_US.utf8");
    std::wcout << L"Substring to find: \"" << target << L"\"\n"
               << L"String to search: \"" << origin << L"\"\n\n";
    for (; (result = std::wcsstr(result, target)) != nullptr; ++result)
        std::wcout << L"Found: \"" << result << L"\"\n";
}

가능한 출력:

Substring to find: "ベータ"
String to search: "アルファ, ベータ, ガンマ, アルファ, ベータ, ガンマ."
Found: "ベータ, ガンマ, アルファ, ベータ, ガンマ."
Found: "ベータ, ガンマ."

참고 항목

주어진 부분 문자열의 첫 번째 발생을 찾음
( std::basic_string<CharT,Traits,Allocator> 의 public member function)
문자 부분 문자열의 첫 번째 발생을 찾음
(function)
와이드 문자열에서 와이드 문자의 첫 번째 발생을 찾음
(function)
와이드 문자열에서 와이드 문자의 마지막 발생을 찾음
(function)