I have, a float number. I would like to print it inside a messagebox. How to do it?
MessageBox(hWnd, "Result = <float>", L"Error", MB_OK);
update:
I do this and it prints out chinese characters inside the messagebox.
float fp = 2.3333f;
sprintf(buffer,"%f",fp);
MessageBox(hWnd, LPCWSTR(buffer), L"Error", MB_OK);
As you are using the
wchar_tversions of the Win32-functions you should useswprintfinstead ofsprintf:To avoid potential buffer overruns you could also use
_snwprintf:Or better yet, use
std::wostringstreamdeclared in<sstream>: