-2

Win32 プログラムをコーディングしています。X 位置と Y 位置を画面にテキスト出力したいのですが、SHORT を TCHAR に変換する方法を知りたいです。atoi または itoa 関数を使用しないでください。

これはおもちゃのプログラムで、マウスの位置をテキストで出力したいのですが、short を TCHAR に変換する方法がわかりません。

4

3 に答える 3

1

stringstream を使用できます。

#include <sstream>

std::stringstream ss("");
ss << nX << " " << nY;

TextOut(GetDC(hWnd), 100, 100, reinterpret_cast<TCHAR *>(ss.str().c_str()), ss.str().size());
于 2013-12-18T19:06:03.980 に答える
0
SHORT myVal;
TCHAR buf[32]; // 32 is big enough to contain a 16-bit int as a string

_stprintf_s(buf,ARRAYSIZE(buf),"%hd",myVal);
// now buf contains the text as a TCHAR
于 2013-12-18T18:09:23.900 に答える