Weird behavior when assigning one char array to another char array using char : <p>When I try to copy one element from char array to a char and then from same char to another char array, second char array gives weird output, usually containing whole string from first char array. This happens only when second char array is not initialized. My question is how char is able to transfer whole string to another char array.</p>

<pre><code>int main()
{
    char a[10] = "ababababa";
    char b[5];
    char temp;

    temp=a[1];
    b[0]=temp;

    std::cout&lt;&lt;b;

}
</code></pre>

<p>While using g++ I get <code>b{�Uarabababa</code>
While using clang++ I get <code>b�U</code></p>

<p>Content between <code>b</code> and <code>U</code> changes every time program is run.</p>
