+ 1

What is the difference between following declarations??(in C)

int* arr1[8]; int (*arr2)[8]; int *(arr3[8]);

25th Nov 2016, 9:37 AM
Vaibhav Miniyar
Vaibhav Miniyar - avatar
2 Réponses
+ 1
int* arr1[8] and int *(arr3[8]) are same and it means that it will create a pointer array of size 8, i.e. instead of normal array of integers it will be array of pointers and it can store 8 addresses of integer variables. as for the second syntax int (*arr2)[8] defines a pointer to an array: int b[8]; int (*arr2)[8] = &b; now arr2 will have the same values as that of b.
25th Nov 2016, 1:13 PM
EDEEPAT
0
First and third are same result and defined pointer to an array. But in second declaration you defined an array of pointers
25th Nov 2016, 12:22 PM
Mehdi Alikhan
Mehdi Alikhan - avatar