Hello I am learning c in school and having a little confusion on this problem.
That is,
b
is two d array, and I am trying to implement around printing values and the adress,
but why is *(b+1)
giving the same thing as b+1
?
I thought *(b+1)
would give the value of the first element of the second row.
and if I change printf("%p\n", *(b+1))
to printf("%d\n", *(b+1))
, it just gives a garbage value.
Why is it working like this?
I appriciate any feedback! thank you
int main()
{
int b[3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
printf("b:\n");
print_2d_array(3, 4, b);
printf("\n");
printf("%p\n", b);
printf("%p\n", *(b+1));
printf("%p\n", b+1);
return 0;
}
Output is like this,
b:
0 1 2 3
4 5 6 7
8 9 10 11
0x7ffeecee6730
0x7ffeecee6740
0x7ffeecee6740