M
mehul raval
hi ,
regarding ur query as to print the individual elements here is the
poss way to do it.
# include <stdio.h>
void main()
{
int (*Data)[4];
int A[4]={1,2,3,4};
Data=&A;
/* A is a pointer to an array of 4 int.*/
printf(" %d %d",*((*Data)),*((*Data)+1));
return;
}
this prog will print both the elements and similarly all the elements
can be printed with the format *((*Data)+ i).
in the prog u had initalized Data to be a ptr to a 2D array with the
no of columns specified but the no rows werent.
*Data pts to the 1st row in such case and then other rows can be
accessed by *(Data)+ (rowno) and llly the contents by *(*(Data)+
(rowno)),thats the format.
Hope it helps.
mehul
regarding ur query as to print the individual elements here is the
poss way to do it.
# include <stdio.h>
void main()
{
int (*Data)[4];
int A[4]={1,2,3,4};
Data=&A;
/* A is a pointer to an array of 4 int.*/
printf(" %d %d",*((*Data)),*((*Data)+1));
return;
}
this prog will print both the elements and similarly all the elements
can be printed with the format *((*Data)+ i).
in the prog u had initalized Data to be a ptr to a 2D array with the
no of columns specified but the no rows werent.
*Data pts to the 1st row in such case and then other rows can be
accessed by *(Data)+ (rowno) and llly the contents by *(*(Data)+
(rowno)),thats the format.
Hope it helps.
mehul