0

我正在调用一个在输出流中输出宽字符的函数。考虑:-

wcout<<GetOutput();

函数的定义是这样的:-

const wchar_t* GetOutput()
{
        std::wstringstream stringStream;
        stringStream << out_name << " " << out_type << out_subtype;
        wchar_t* check = new wchar_t[stringStream.str().length() + 1];
        wcscpy(check, stringStream.str().c_str());
        return check;
}

现在,当在 cmd 上调用这个函数时,它给了我正确的输出。但是,当在 linux(WSL) 上调用相同的函数时,我得到的输出是这样的地址:-

0x1ef110ad0

为什么会这样?

编辑:- 变量的定义如下:-

const std::wstring out_name = L"My Name";
const std::wstring out_type = L"Type1";
const std::wstring out_subtype = L"SubType1";
4

0 回答 0