converting float to LPCWSTR

c++, winapi

Solution

You could use `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;
}

and create an `LPCWSTR` from it if required, or just use the `std::wstring`.

Problem

So I have, let's say ``` float x; ``` and I have ``` LPCWSTR message=L"X is"; ``` how can I create a LPCWSTR with the message "X is [x]" ?

Original source