Per the msdn example here, I am trying to convert char* (specifically from main() argv) to a wchar_t*
the code works alright by itself but when i try to wrap it in a function for reuse, i find that the wchar_t* dst is being garbled upon exit of the wrapping fuction. i get an error for uninitialized memory for passing in a pointer i didn't initialize outside of the function, and an access violation after it exits.
But that's the thing. i WANT to pass in a pointer to a wchar_t that isn't set, set it in function, and use the set value after the fact. what am I doing wrong here?
here's my example code:
int main(int argc, char* argv[])
{
    wchar_t* dst;
    for (int i = 0; i < argc; i++) 
    {           
        char_str_to_wchar_t_str(dst, argv[i]);
        
        // do some stuff with dst, like print it.
        // but by the time i get here, dst is corrupted. why? 
        // and what do i do to fix it?
        
    }
}
static size_t char_str_to_wchar_t_str(wchar_t* dst, char* src)
{
    size_t newsize = strlen(src) + 1;
    dst = new wchar_t[newsize]; // Convert char* string to a wchar_t* string.
    size_t convertedChars = 0;
    mbstowcs_s(&convertedChars, dst, newsize, src, _TRUNCATE);
    // at this point, dst is correctly converted and i can read it fine in the debugger. 
    return convertedChars;
}
EDIT: don't see how the question this was associated with helps. also as an aside, i'm doing this because i'm up-converting some c code to c++. it looks like converting it to a std::wstring and returning that accomplishes the same basic thing, and cleaner IMO, but the original question remains: if i'm passing a pointer as an argument into the function, then i should be able to use that pointer after the function exits, what's wrong with that?
