I received Runtime error whenever I use malloc() for Dynamic memory allocation in C. The same code is accepted if I use static array. I don't know if I use malloc in wrong way. How can I do Dynamic memory allocation in C that won't yield RTL?
Here is a sample code of my malloc use
Code: Select all
#include<stdlib.h>
/*Allocating memory for graph*/
G=(int **) malloc((size_t) sizeof(int *)*n);
for(loop=1;loop<=n;loop++){
G[loop]=(int *) malloc((size_t) sizeof(int)*n);
nonaccessible[loop]=1;
}
/*End of allocation*/