Returning pointer to wchar_t from function
<p>Why this code doesn't work?</p>

<pre><code>wchar_t path[300];
wchar_t *PathCreator(wchar_t *dir, wchar_t *fileName)
{
    int j = 0;
    while(j &lt; 300)
    {
        path[j] = '\0';
        j++;
    }
    int i;
    i = 0;
    while(*dir != '*')
    {
        path[i] = *dir;
        i++;
        dir++;
    }
    wchar_t *t = fileName;  
    while(*t != '\0')
    {
        path[i] = *t;
        i++;
        t++;
    }
    path[i] = '\0';
    //std::wcout &lt;&lt; path &lt;&lt; std::endl;
    return path;
}
int _tmain(int argc, _TCHAR* argv[])
{ 
    std::wcout &lt;&lt; PathCreator(L"A",L"B");
}
</code></pre>
