std::wcspbrk(3)
π NAME π
Okay bestie, welcome to the std::wcspbrk(3) page from the C++ Standard Libary manual. The NAME is literally std::wcspbrk β std::wcspbrk. Itβs giving βwide character string pointer breakβ energy, and weβll get to why in a sec. β¨
β¨ Synopsis β¨
Defined in header <cwchar>:
const wchar_t* wcspbrk( const wchar_t* dest, const wchar_t* src );
wchar_t* wcspbrk( wchar_t* dest, const wchar_t* src );
So what does it do? It finds the first character in the wide string pointed to by dest, that is also in the wide string pointed to by src. Thatβs it. Thatβs the vibe. π₯
πΈ Parameters πΈ
destβ pointer to the null-terminated wide string to be analyzed.srcβ pointer to the null-terminated wide string that contains the characters to search for.
π Return value π
It hands you a pointer to the first character in dest, that is also in src, or a null pointer if no such character exists. No cap. π
π¦ Notes π¦
The name stands for βwide character string pointer breakβ, because it returns a pointer to the first of the separator (βbreakβ) characters. Cute, right? Itβs literally in the name, iykyk. π
π Example π
// Run this code
#include <cwchar>
#include <iomanip>
#include <iostream>
int main()
{
const wchar_t* str = L"Hello world, friend of mine!";
const wchar_t* sep = L" ,!";
unsigned int cnt = 0;
do
{
str = std::wcspbrk(str, sep); // find separator
std::wcout << std::quoted(str) << L'\n';
if (str)
str += std::wcsspn(str, sep); // skip separator
++cnt; // increment word count
} while (str && *str);
std::wcout << L"There are " << cnt << L" words\n";
}
π Output π
" world, friend of mine!"
", friend of mine!"
" of mine!"
" mine!"
"!"
There are 5 words
π See also π
wcscspnβ returns the length of the maximum initial segment that consists of only the wide characters not found in another wide string (function).wcschrβ finds the first occurrence of a wide character in a wide string (function).strpbrkβ finds the first location of any character from a set of separators (function).- C documentation for
wcspbrk.
Sign-off cuteness: source http://cppreference.com Β· version/date 2024.06.10 Β· page std::wcspbrk(3) π«Άπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms