Array of const char*
<p>I'm writing a C++ program that uses the RRD libraries that require an array of 'const char*' for their functions. I thought I could just declare the array, and then initialize each element of the array, but changing one, changes all of them. Obviously I'm missing something.
Here's an example similar to the code I am writing (i.e. it exhibits the same problem).</p>

<pre><code>string intToString(long i)
{
    stringstream ss;
    string s;
    ss &lt;&lt; i;
    s = ss.str();
    return s;
}

int main(){
        const char* av[5];
        int i = 0;
        int j = 0;
        for(i=0;i&lt;5;i++){
                j= 0;
                av[i] = intToString(i).c_str();
                for(j=0;j&lt;5;j++){ cout &lt;&lt; j &lt;&lt; " : " &lt;&lt; av[j] &lt;&lt; endl;}
        }   

}
</code></pre>

<p>Any help would be appreciated.</p>
