EDIT
This is not a question on array decay from char [1] and char *. I know what array decay is for 1D arrays. It however seems different for char [1][1] and char ** since they are not even compatible types.
I know that I can go from one of the types char [1] and char * to the other. However, it seems not as easy with char [1][1] and char **.
In my main function I have:
int main(void) {
char a[1][1];
a[0][0] = 'q';
printf("a: %p\n", a);
printf("*a: %p\n", *a);
printf("**a: %p\n", **a);
}
I'm of course compiling with warnings and I know that gcc complains about the 6th line as **a is actually of type char and not a pointer type. However running the code shows that a and *a are actually the same pointer but **a is as expected something else (0x71 which I assume is related to 'q' in some way).
I'm trying to make sense of this and it seems that because *a and a are equal **a must also be equal to a because **a = *(*a) = *(a) = *a = a. It seems that the only error in this reasoning can be the types of a, *a, **a.
How is a actually stored in memory? If a is a pointer to another memory location (in my case 0x7fff9841f250) then surely *a should be the value at that memory address which in my case is also 0x7fff9841f250. So then **a would be the value at 0x7fff9841f250 which is the same value as 'a'... It seems that I cannot view the 2D array char a[1][1] as pointers in a way that makes sense. But then how can I think of this type? What is the type and what does a, *a, **a, a[0], a[0][0] actually mean?
I have already seen Incompatible pointer type but it does not explain what the operations *a, **a, a[0], a[0][0] are actually doing.