Consider the following program.
#include <stdio.h>
int main()
{
int a[10]={0};
printf("%p %p\n", a, &a);
printf("%d %d\n", *a, *(&a));
return 0;
}
a and &a are same. But *a and *(&a) are not. I am out of answers. Please help.
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.
There is no “array base pointer”, i.e. there no pointer variable that points to the array. The name of the array refers to the array itself. Therefore you can not take an address of
a, instead,&ais handled as a special case.When you use the name of an array in an expression, it decays into a pointer that points to the first element of the array. However,
&andsizeofoperators are exceptions.ANSI C specifies that
&ameans the address of the array itself, and its type is “pointer to array”, not “pointer to array element”.In pre-ANSI compilers, &a would cause a warning.