Re: Passing address of multidimentional array

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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 pointer
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.
No - they are still different with all consequences.

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
.



Relevant Pages

  • Re: Properties
    ... public string Name ... The fact of the matter is that by adding having to add a field declaration ... There is no reason that you have given why this cannot be done. ... property but where theres a property theres a field and hence theres no ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: identifiers and modules
    ... Do you have a reason why a language should allow it? ... (let ((foo (transform-value foo))) ...)) ... working on a large nested function can easily use the wrong variable ... Given that allowing an inner declaration to override an outer ...
    (comp.lang.scheme)
  • Re: identifiers and modules
    ... Do you have a reason why a language should allow it? ... (let ((foo (transform-value foo))) ...)) ... working on a large nested function can easily use the wrong variable ... Given that allowing an inner declaration to override an outer ...
    (comp.lang.scheme)
  • RE: ActiveCell.Value copies unwanted currency format of source cel
    ... I just noticed something in my declaration of the variables but I'm not sure ... "JMB" wrote: ... decimals may be displayed). ... I cannot see any logical reason ...
    (microsoft.public.excel.programming)
  • Re: Scope of implied-do index
    ... but it seems like at least part of the reason. ... Implied DO variables with scope of the implied DO are one of my least ... but I can avoid using statement functions). ... is no place "reasonable" to put a declaration of them, ...
    (comp.lang.fortran)