0
Why is ptr = a; shows error?
int a[2][3] = { }; int *ptr; int a; ptr = a; printf("%d",*(ptr[2]+3));
5 Réponses
+ 7
The Pointer to an Array is always the Memory Adress of the first Element.
https://www.sololearn.com/learn/C/2962/
+ 5
You must assign the memory address to ptr (= &a).
https://www.sololearn.com/learn/C/2933/
+ 5
You have two variables named <a>, one is an int array ...
int a[2][3] = {};
and another one below an int
int a;
I'm not sure which of these you're pointing to with <ptr>, but from the printf call it seems you want to use the array, so remove that `int a;` from your code, and test again.
0
But array has its own pointer so why mention & ?
0
cause is that pointer must be following way
*ptr=a or else int *ptr=a