[Info-vax] Dave Cutler, Prism, DEC, Microsoft, etc.
toby
toby at telegraphics.com.au
Thu Dec 17 16:58:16 EST 2009
On Dec 17, 2:42 am, Michael Kraemer <M.Krae... at gsi.de> wrote:
> toby schrieb:
>
>
>
>
>
> > On Dec 16, 9:40 pm, JF Mezei <jfmezei.spam... at vaxination.ca> wrote:
>
> >>toby wrote:
>
> >>>In a standard C compiler where mystring is an array,
> >>>mystring , &mystring , or &mystring[0] are all the same pointer.
>
> >>In ANSI C, &mystring is not accepted.
>
> > My gcc 4.1.2 with -ansi -pedantic accepts it. It always gives a
> > warning, "assignment from incompatible pointer type".
>
> > e.g.
> > char a[], *p;
> > p = &a;
>
> which seems correct, IMHO.
> p is of type "char *",
> &a is of type "char **".
No, &a for an array has the same bit pattern as a and &a[0]
> So mystring and &mystring are not the same,
> mystring and &mystring[0] are.
If a had been a pointer e.g. char*, then yes, then &a would be the
address of pointer a and typed char** - not the value of a. But arrays
behave slightly differently.
More information about the Info-vax
mailing list