The problem is that TSTR can be either char or wchar_t, so there's not really much choice beyond allocating an array of TCHAR and copying one into the other with a function that recognizes TCHAR and handles it accordingly:
TCHAR *ttemp = new TCHAR[strlen(temp) + 1]
When you see a capital T (as in LPTSTR) it means the code works with Unicode.
Rather, it means that the code accepts either narrow or wide characters. The Win32 API treats wide characters as UTF-16 encoded Unicode, so while it's technically correct to say that it means you're working with Unicode, I still think it's important to make the distinction between wide characters and Unicode characters as well as the variant nature of TCHAR which depends on a compilation setting. ;)
You can do what deceptikon suggested or just declared the string as
Oh, if only it were always that simple. Yes, if you take the question at face value then always using TCHAR is certainly the better option. But I treated it like an example of the issue rather than the actual code and included the possibility that the OP doesn't have any control over the type of temp, which isn't an unreasonable assumption in my view.