error in a C program using dynamic memory allocation and array : programming in C for finding maximum in 2D aaray using dynamic memory allocation.


int main()
{

int i,arr[m][n],j,m,n;

int max=0;

int *ptr;

printf("enter the value m");

scanf("%d",m);

printf("enter the vaue of n");

scanf("%d",n);

ptr=(int*)malloc(m*n*4);

printf("enter the values\n");

for (i=0;i<m;i++)

{

   for(j=0;j<n;j++)



{

scanf("%d",((ptr+i*n)+j));

}

}

	max=arr[0][0];

for (i=0;i<m;i++)

{

   for(j=0;j<n;j++)



{

     if(max<*((ptr+i*n)+j));   
     max=*((ptr+i*n)+j);

	

     }

}

printf("%d",max);

}


