By definition, it is a pointer variable that points to an array.
my code print the values of three element array .
my question why the result is right usingprintf("Value at %p = %d\n", ptr2arr +i, *(ptr2arr[0]+i));
and wrong result except the first value while using printf("value at %p =%d\n" ,ptr2arr+i,*(ptr2arr[i]))
#include <stdio.h>
int main(int argc, char* argv[])
{
int arr[3] = {1,2,3};
int (*ptr2arr)[3];
int i;
ptr2arr = &arr;
for(i = 0; i<3; i++)
{
printf("Value at %p = %d\n", ptr2arr +i, *(ptr2arr[0]+i));
}
printf("-------------------\n");
for(i = 0; i<3; i++)
{
printf("value at %p =%d\n" ,ptr2arr+i,*(ptr2arr[i]));
}
return 0;
}
`