你好朋友我怎樣才能將類型「int」轉換爲類型「LPCSTR」?我想將變量「int cxClient」賦予「MessageBox」函數的第二個參數「LPCSTR lpText」。以下是示例代碼:如何將類型「int」轉換爲在Win32中輸入「LPCSTR」C++
int cxClient;
cxClient = LOWORD (lParam);
MessageBox(hwnd, cxClient, "Testing", MB_OK);
但它不起作用。下面的功能是「消息框」功能的方法簽名:
MessageBox(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
由於該問題被標記爲C++,也許C++的答案會更好 –
@DavidHe ffernan - 用ostringstream也添加一個。 – user93353
哇!我知道了。現在「MessageBox」函數可以顯示我想要的變量:D。以下是我的工作代碼: #include using namespace std; #ifdef _UNICODE wostringstream oss; #else ostringstream oss; #endif oss << cxClient; MessageBox(hwnd,oss.str()。c_str(),「Testing」,MB_OK); 非常感謝你 :D –