Re: i think i found
On Mar 9, 7:09*pm, j...@panix.com (Joe keane) wrote:
> How about this?
>
> * * int f(int x)
> * * {
> * * * * int a[2];
> * * * * int *p;
>
> * * * * p = &a[0];
> * * * * *p = 2;
> * * * * ++p;
> * * * * *p = 3;
> * * * * /* printf("%d %d\n", a[0], a[1]); */
> * * }
>
> That pretty much has to work, right?
No it does not. The function fails to return an int as promised in
the declaration. I don't remember whether this is undefined behavior
or a constraint violation.
>
> So what's the deal with arrays of arrays?
Since your sample code does not have any arrays of arrays, we have no
idea what your question is. Did you perchance mean something like
int f(int x)
{
int a[4][3];
int (*p)[3];
p = &a[0];
(*p)[1] = 2;
++p;
(*p)[2] = 3;
/* printf("%d %d\n", a[0][1], a[1][2]); */
return 0;
}
|