Stack around the variable ' ' was corrupted in c++ : <p>I m getting a run-time error when I try to call a constructor , and I think I m not doing right the memory deletion. Here is my construcor :</p>

<pre><code>const int id_ferma;
int suprafata;
int nr_produse;
char* produse[];

Ferma(int id_ferma, int suprafata, int nr_produse, char* produse[]) :id_ferma(id_ferma){
        this-&gt;suprafata = suprafata;
        this-&gt;nr_produse = nr_produse;
        for (int i = 0; i &lt; nr_produse; i++){
            this-&gt;produse[i] = new char[strlen(produse[i]) + 1];
            strcpy(this-&gt;produse[i], produse[i]);
            cout &lt;&lt; produse[i] &lt;&lt; endl;
        }
    }
</code></pre>

<p>And here is my destructor:</p>

<pre><code>~Ferma(){
    for (int i = 0; i &lt; nr_produse; i++){
            if (this-&gt;produse[i] != NULL)
                delete produse[i];
    }
}
</code></pre>

<p>And main:</p>

<pre><code>int main(){
        char* produse1[] = { "Lapte oaie", "Branza vaca", "Muschi de porc", "Oua de gaina" };
        for (int i = 0; i &lt; 4; i++){
            cout &lt;&lt; produse1[i];
        }
        Ferma f1(14, 1500, 4, produse1);
    }
</code></pre>
