I have written the following function which it is going to print out the value of an environment variable, but when I compile it, it shows me the following error:
 error C2760 : syntax error : unexpected token 'new', expected ';'
warning C4244: 'initializing': conversion from 'DWORD' to 'TCHAR', possible loss of data
The code I have written:
template<typename T>
void EnvironmentVariableParser(T arg_variable_name) 
{
    PTSTR pszTemp, pszValue = NULL;
    auto dwResult = GetEnvironmentVariable(arg_variable_name, pszValue, 0);
    if (dwResult != 0) 
    {
        auto size = dwResult * sizeof(TCHAR);
        pszTemp = new PTSTR(size);
        pszValue = reinterpret_cast<PTSTR>(pszTemp);
        GetEnvironmentVariable(arg_variable_name, pszValue, size);
        std::cout << arg_variable_name << "=" << pszValue << std::endl;
        delete pszValue;
    } 
    else 
    {
        std::cout << arg_variable_name << "=<unknown value>" << std::endl;
    }
}
is that possible to cast new operator output to something like PTSTR?
 
    