C++ pointer not storing value : <pre><code>word  word::Addstr(char * &amp;arr)
{
    char * baka = nullptr;
    if (sent != nullptr)
    {
        baka = new char[size + strlen(arr) + 3];
        for (int i = 0; i &lt; size; i++)
        {
            baka[i] = sent[i];
        }
        baka[size] = ' ';
        int a = 0;
        for (int i = size +2; i &lt; size + strlen(arr) + 3; i++)
        {
            baka[i] = arr[a];
            a++;
        }

    }
    else
    {
        baka = new char[strlen(arr) + 1];
        for (int i = 0; i &lt; strlen(arr) + 1; i++)
        {
            baka[i] = arr[i];
        }
    }
    word ustad(baka);
    return ustad;
}
</code></pre>

<p>Here in the second loop char *baka is not storing arr[]'s value. I have sent the char pointer by reference yet still it's not working.</p>

<pre><code>for (int i = size +2; i &lt; size + strlen(arr) + 3; i++)
        {
            baka[i] = arr[a];
            a++;
        }
</code></pre>

<p>The constructors and all other things are accurate. Baka stores value in the first loop but in the second one it doesn't. Even here:</p>

<pre><code>baka[size] = ' ';
</code></pre>

<p>Can someone pleases help with this!</p>
