gpt4 book ai didi

c++ - 将 float 转换为 LPCWSTR

转载 作者:太空狗 更新时间:2023-10-29 23:33:42 26 4
gpt4 key购买 nike

所以我有,比方说

float x;

我有

 LPCWSTR message=L"X is";

如何用消息创建 LPCWSTR

"X is [x]"

?

最佳答案

你可以使用 wstringstream :

#include <string>
#include <sstream>
#include <iostream>

int main()
{
float x = 0.1f;
std::wstringstream s;
s << L"X is " << x;
std::wstring ws = s.str();
std::wcout << ws << "\n";

return 0;
}

并根据需要从中创建一个 LPCWSTR,或者只使用 std::wstring

关于c++ - 将 float 转换为 LPCWSTR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10834786/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com