C++ char array gives strange output
<p>I am trying to create a char array in a function, pass it to main, and the print it out.  This is giving me a string of random characters like this: ╠╠╠╠╠╠╠╠↑</p>

<p>Also, when I check the number of characters before the '\0' terminator the first output will give me the number of characters inputted, but the second output will give me 49 (size of the buffer), so I feel this is a problem involving the NULL terminator, but Im not sure how to resolve it.  .  </p>

<p>I have recreated the issue outside of my real project file, so the code is less messy and shown below.  </p>

<pre><code>const int BUFFER = 50;

char* getWord()
{
        char word[BUFFER];

    cout &lt;&lt; "Please enter a word: ";
    cin.getline(word, BUFFER);
        cout &lt;&lt; "The word is: " &lt;&lt; word; // This prints out the word with no problems..

    return word;
}

int main()
{
        char* wordPtr;

    wordPtr = getWord();
    cout &lt;&lt; "Your word is: " &lt;&lt; wordPtr &lt;&lt; "\n";  // This prints out random symbols.
    system("PAUSE");

    return 0;
}
</code></pre>

<p>Any help is greatly appreciated.</p>
