Afficher un message
Vieux 10/05/2008, 13h09   #11
pete
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Two dimensional array Question

mdh wrote:
>>
>>> The exercise associated with this, used the construct
>>> *p = arr[1 or 0 ] to point to either the "first" or "second" row of
>>> the array. Does the compiler "know" where to point to because it has
>>> been given this information by the declaration of "13" in arr[2][13].
>>> Hopefully this makes sense too!

>> Yes and yes.
>>

> I was in a hurry to get to work this am...so forgot to ask this.
> In a multidimensional array, one can simply drop the second []? as in
> *p=arr[i] and this is legal?
> Thanks.


It's legal regardless of whether or not
you understand what you're writing.
But it's better if you realize that

*p = arr[i];

means the same thing as

*p = &arr[i][0];

because

&arr[i][0] means &*(*(arr + i) + 0)

which can be simplified to

(*(arr + i) + 0)
*(arr + i)
arr[i]

--
pete
  Réponse avec citation
 
Page generated in 0,04610 seconds with 9 queries