hello.. I am learning C using the book Let US C.. I have a doubt regarding pointers... I want to pass a 2d array to a functiona nd display the elements using pointers.. the function prototype is
i want to pass the 2d array
the function definition is
here though the output is correct i am unable to understand the expression p=(int*)&q[i].. Can anybody please explain it as i am a beginner.. thank you
Code:
void show(int(*q)[4],int,int);
Code:
int a[3][4]={{1,2,3,4},
{5,6,7,8},
{9,10,11,12}
};
show(a,3,4);
Code:
void show(int (*q)[4],int r,int c){
int i,j;
int *p;
for(i=0;i<r;i++){
printf("\n");
p=(int *)&q[i];
for(j=0;j<c;j++)
printf("%3d",*(p+j));
}
}
Comment