|
|
arnuld <NoSpam@xxxxxxxxxx> writes:
>> On Mon, 28 Apr 2008 07:25:53 +0000, Richard Heathfield wrote:
>> Given the correct call foo(notanarrayofpointers), we can deduce that foo
>> takes as its parameter a char (*)[6], NOT a char **.
>
> I did not know that passing a 2D array to a function results in <pointer
> to whole array>. Thanks for telling me this C feature :)
Not to the whole array, just to the first element.
This is nothing more than one case of the more general rule that an
expression of array type is, in most contexts, converted to a pointer
to its first element (the exceptions are when the array expression is
(a) the operand of a unary "&", (b) the operand of "sizeof", or (c) a
string literal in an initializer, used to initialize an array object).
A 2D array is nothing more than an array of arrays. Everything about
2D arrays (syntax, semantics, whatever) follows directly from the
rules for arrays in general.
--
Keith Thompson (The_Other_Keith) <kst-u@xxxxxxx>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
|
|