Re: Passing address of multidimentional array
- From: Victor Bazarov <v.Abazarov@xxxxxxxxxxxx>
- Date: Tue, 03 Jun 2008 16:14:41 -0400
Doug Harrison [MVP] wrote:
On Tue, 03 Jun 2008 21:25:14 +0200, "Cezary H. Noweta"
<chncc@xxxxxxxxxxxxxxx> wrote:
Doug Harrison [MVP] wrote:
All the following are equivalent:
void f(int a[20][30]);
void f(int a[2][30]);
void f(int a[][30]);
void f(int (*a)[30]);
This is the *****only***** context in which array and pointerNo - they are still different with all consequences.
declaration syntax is sort of interchangeable, and it's the reason
the magnitude of the first dimension doesn't matter - all four
declare "a" to be a pointer to an array of 30 ints.
It is as I said.
For example array
declarators (the first three) are not modifiable lvalues, while the last
declarator is.
You are mistaken.
So it is impossible to use ,,a = sth;''
I don't know what that means.
I think Cezary meant to imply that the assignment in 'foo' below is supposed to fail for some reason:
void foo(int a[20][30])
{
int b[5][30];
a = b; // line 4
}
void bar(int (*a)[30])
{
int b[5][30];
a = b;
}
int main()
{
int arr[100][30];
foo(arr);
bar(arr);
}
Of course, since the two declarations are equivalent ('foo' and 'bar' have the same type, essentially), there is no error on line 4.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.
- References:
- Passing address of multidimentional array
- From: goodTweetieBird
- Re: Passing address of multidimentional array
- From: Doug Harrison [MVP]
- Re: Passing address of multidimentional array
- From: Cezary H. Noweta
- Re: Passing address of multidimentional array
- From: Doug Harrison [MVP]
- Passing address of multidimentional array
- Prev by Date: Re: Passing address of multidimentional array
- Next by Date: Re: VC8 Compiler bizarreness
- Previous by thread: Re: Passing address of multidimentional array
- Next by thread: Re: Passing address of multidimentional array
- Index(es):
Relevant Pages
|