I have this piece of code (in the abc function)
matriz = new (nothrow) int*[qnt_objetos]; if (matriz == 0) exit(0); for (int i = 0; i < qnt_objetos; i++) { matriz[i] = new (nothrow) int[tam_mochila]; if (matriz[i] == 0) exit(0); }
matriz is a two-dimensional array declared as such (basically)
int **matriz = NULL;
However, memory space is not allocated when using the new operator. What am I doing wrong? And also, is it better to allocate memory directly in the main function? Doesn't that make the code more illegible?
PS: debugging it on NetBeans (or using the terminal), I got this matriz address = 0x0 ( NULL if I'm not mistaken)
source share