Search code examples
c++winapishorttchar

Convert SHORT to TCHAR?


I am coding a Win32 Program,and I want to text out the X pos and Y pos to the Screen, and I want to know how to convert SHORT to TCHAR. don't use the atoi or itoa function.

This is a toy program, and I want to text out the position of the mouse, but I donnot konw how to convert short to TCHAR.


Solution

  • Maybe you want to convert a unsigned int to a string. You can use std::to_wstring if TCHAR is defined as a WCHAR:

    short x = 123;    
    std::wstring s = std::to_wstring(x);
    

    Then convert s.c_str() to a TCHAR*.