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?

2
  • 1
    Would this answer your question? stackoverflow.com/questions/41473864/pointer-to-array-in-c The accepted answer has a very similar example. Commented Mar 6, 2021 at 17:30
  • 1
    It did, sorry. I had seen that one before, but didn't read it carefully enough. Commented Mar 6, 2021 at 17:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.