In int (*x)[10]; x is a pointer to an array of 10 ints
So why does this code not compile:
int arr[3] ;
int (*p)[3] =arr;
But this works:
int arr[3];
int (*p)[3] =&arr;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
arris an expression that evaluates to anint*(this is the famous ‘arrays decay to pointer’ feature).&arris an expression that evaluates to aint (*)[3].Array names ‘decay’ to pointers to the first element of the array in all expressions except when they are operands to the
sizeofor&operators. For those two operations, array names retain their ‘arrayness’ (C99 6.3.2.1/3 “Lvalues, arrays, and function designators”).