How to convert double to LPCSTR in C++ Win32 API

1 Answer

0 votes
#include <windows.h>
#include <string>  


int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    double d = 12384.8007;

    std::string str = std::to_string(d);

    MessageBoxA(0, str.c_str(), "Info", MB_OK);

    /*
    int MessageBoxA(
        [in, optional] HWND   hWnd,
        [in, optional] LPCSTR lpText,
        [in, optional] LPCSTR lpCaption,
        [in]           UINT   uType
    );
    */
}



/*
run:

12384.800700

*/

 



answered Aug 12, 2024 by avibootz
...