扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

c++中wchar_t字符串拼接的方法是什么

扬州沐宇科技
2024-05-13 10:34:50
c++

在C++中,可以使用std::wstring来表示wchar_t类型的字符串,然后使用+运算符来进行字符串拼接。例如:

#include <iostream>
#include <string>

int main() {
    std::wstring str1 = L"Hello, ";
    std::wstring str2 = L"world!";
    std::wstring result = str1 + str2;

    std::wcout << result << std::endl;

    return 0;
}

在上面的例子中,我们使用std::wstring表示wchar_t类型的字符串,然后使用+运算符将两个字符串拼接在一起,最终输出结果为Hello, world!

扫码添加客服微信