Convert Char To LPCTSTR
Ive coded quite a complicated C programme and stuck on a really simple problem which i cant seem to solve.
That is what im trying to do but with no luck as SetDlgItem requires a LPCTSTR as its third argument and not a char. Any ideas how i can get this working?
char ch = 'a';
SetDlgItemText(hwnd, IDC_S, ch);
Note: Im not looking for the following solution:
As i am required to do it by converting a char to a LPCTSTR
SetDlgItemText(hwnd, IDC_S, "a");
Thanks for any help
makeAshortString = ch;
makeAshortString = '\0';
SetDlgItemText(hwnd, IDC_S, makeAshortString );
LPCTSTR can be either char* or wchar_t*, depending on whether the program is compiled for UNICODE or not. You cannot pass a single char as the third argument. There are several solutions, depending on UNICODE settings -- the first and last solutions below will compile with or without UNICODE.
char a = "a";
wchar_t a = L"a";
TCHAR a = _TEXT("a");