#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
int **a;
int i,j,p;
a=(int**)malloc(3*sizeof(int*));
for(i=0;i<3;i++)
{
*(a+i)=(int*)malloc(2*sizeof(int));
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",(*(a+i)+j));
}
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{
p=*(*(a+i)+j);
printf("%d ",p);
}
}
}
}
In this code i am dynamically allocating memory to my matrix using pointers... but i am able to enter value only to the first row and the rest the address of the pointer is being printed as seen below..
Only the first row elements are taken in and output of the first row is given but the second row onwards no input is taken but garbage value is printed. help me figure out the error. Please help me figure out the mistake in this code.