--- In [email protected], LiGang <[EMAIL PROTECTED]> wrote:
>
> I have some questions about the address of an array, Please look at the
> following simple code:
>
> ===================================================
> #include <stdio.h>
>
> int main(void)
> {
> int inter[3]={1,2,3};
>
> printf("inter is %p_____and &inter is %p\n",inter,&inter);
> printf("*&inter is %d\n",*&inter);
> printf("*inter is %d\n",*inter);
>
> return 0;
>
> }
> ===================================================
>
> Clearly, inter==&inter, but why *inter and *&inter is not identical?
If you change the code to following, and run it through Gimpel's
PC-Lint, it gives you a clue:
int main(void)
{
int inter[3] = {1, 2, 3};
int **pp = &inter; /* == &inter[0] ? */
return **pp; /* == 1 ? */
}
Error 64: Type mismatch (initialization) (int ** = int (*)[3])
(for the pp initialisation)
inter is an array, not just an int *, and taking its address is not
the same as taking the address of an int *.
However, I am not that familiar with the C standard, and I would also
being interested to see the relevant section that defines the
behaviour you describe.
John