For the following code:
int (*ptr)[10];
int a[10]={99,1,2,3,4,5,6,7,8,9};
ptr=&a;
printf(\"%d\",(*ptr)[1]);
What should
int(*)[10]
is a pointer to an int array with 10 members. i.e it points to int a[10]
.
where as int *[10]
is array of integer pointers
#include
int main()
{
int *ptr[10];
int a[10]={0,1,2,3,4,5,6,7,8,9};
printf("\n%p %p", ptr[0], a);
*ptr=a; //ptr[0] is assigned with address of array a.
printf("\n%p %p", ptr[0], a); //gives you same address
printf("\n%d",*ptr[0]); //Prints zero. If *ptr[1] is given then *(ptr + 1) i.e ptr[1] is considered which is uninitialized one.
return 0;
}