I have this code to allocate and initialize:
nw = new int*[V];
for (w = 0; w < V; w++) {
nw[w] = new int[K];
for (k = 0; k < K; k++)
nw[w][k] = 0;
}
and this to free memory:
if (nw) {
for (int w = 0; w < V; w++) {
if (nw[w])
delete nw[w];
}
The program compile and runs, but, when its try to deallocate memory, fails. The program not always fails at the same value of w.
Any ideas?