I don't know why I am getting warnings for the following code.
#include<stdio.h>
#include<malloc.h>
int main()
{
int **p;
int i,j;
for(i=0;i<5;i++)
{
if(i==0)
p=(int*)malloc(1*sizeof(int));
else
p=(int*)realloc(p,(i+1)*sizeof(int));
p[i]=(int*)malloc(5*sizeof(int));
for(j=0;j<5;j++)
{
p[i][j]=j;
}
}
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
printf("%5d",p[i][j]);
printf("\n");
}
return 0;
}
Is there any other way to allocate memory dynamically for a double pointer.
This compiles with no warning