std::wcscat(3)
π NAME π
ok so this is the std::wcscat(3) page, and it lives in the C++ Standard Library β yeah, the whole big C++ thing. and the function itself is, iconic behaviour, literally called std::wcscat. we love a page that names itself. slay.
β¨ Synopsis β¨
first things first, bestie, it's defined in header <cwchar> π like that's where it lives, that's its home.
wchar_t* wcscat( wchar_t* dest, const wchar_t* src );
ok so what does it do: it takes a copy of the wide string that src points at and appends it to the end of the wide string that dest points at. and the way it pulls that off? the wide character src[0] straight up replaces the null terminator sitting at the end of dest. bold move honestly. and the resulting wide string? null-terminated, obviously. we stay tidy. π
GIRL. LISTEN. the behaviour is undefined if the destination array isn't big enough to hold the contents of bothsrcanddestplus the terminating null wide character. like, undefined undefined. no cap. π
also undefined: the behaviour if the strings overlap. do not do the overlapping thing. it's giving disaster. π
πΈ Parameters πΈ
destβ pointer to the null-terminated wide string you're appending to. the main character, the one getting stuff added πsrcβ pointer to the null-terminated wide string you're copying from. the contributor. the guest star. π¦
π Return value π
it returns a copy of dest. that's it, that's the return. cute, simple, gives you back what you handed it. π«Ά
π Example π
// Run this code
#include <clocale>
#include <cwchar>
#include <iostream>
int main(void)
{
wchar_t str[50] = L"ΠΠ΅ΠΌΠ»Ρ, ΠΏΡΠΎΡΠ°ΠΉ.";
std::wcscat(str, L" ");
std::wcscat(str, L"Π Π΄ΠΎΠ±ΡΡΠΉ ΠΏΡΡΡ.");
std::setlocale(LC_ALL, "en_US.utf8");
std::wcout.imbue(std::locale("en_US.utf8"));
std::wcout << str << '\n';
}
Possible output:
ΠΠ΅ΠΌΠ»Ρ, ΠΏΡΠΎΡΠ°ΠΉ. Π Π΄ΠΎΠ±ΡΡΠΉ ΠΏΡΡΡ.
look at that. two std::wcscat calls and a space in between and the string is built. we love to see it. the std::setlocale(LC_ALL, "en_US.utf8") and std::wcout.imbue(std::locale("en_US.utf8")) lines are there so the wide characters actually print properly β thoughtful king behaviour. π₯
β See also β
wcsncatβ appends a certain amount of wide characters from one wide string to another (function) β the "I only want some of it" version πstrcatβ concatenates two strings (function) β same energy but the narrow-char edition πwcscpyβ copies one wide string to another (function) β no appending, just a straight copy gig π§- C documentation for
wcscatβ the og C version, for when you wanna cross-reference π
ok that's the whole page bestie, you're officially a std::wcscat expert, iykyk π
β¨
made with love on cppreference.com, version 2024.06.10 β mwah, go forth and concatenate responsibly π
π¦ 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