1

Usually I feel like I understand the initialization from incompatible pointer type error, but I'm a bit confused here.

#include <stdio.h>

int main() {
    int a[10];
    int *p = a;   // fine
    int *q = &a;  // incompatible, expected
    int **z = &a; //incompatible, unexpected

    return 0;
}

I assumed that the variable a is interpreted as an int* pointer to the first element of a, a[0]. So I expected int* q = &a to give me an incompatible warning, but I thought int** z = &a would be correct...?

How is one supposed to actually do this?

chqrlie
  • 131,814
  • 10
  • 121
  • 189
user49404
  • 732
  • 6
  • 22
  • 1
    Would this answer your question? https://stackoverflow.com/questions/41473864/pointer-to-array-in-c The accepted answer has a very similar example. – KamilCuk Mar 06 '21 at 17:30
  • 1
    It did, sorry. I had seen that one before, but didn't read it carefully enough. – user49404 Mar 06 '21 at 17:43

0 Answers0