delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/25/06:43:34

From: eyal DOT ben-david AT aks DOT com
To: blizzar AT hem1 DOT passagen DOT se
cc: djgpp AT delorie DOT com
Message-ID: <4225655A.003F5B2A.00@aks.com>
Date: Tue, 25 Nov 1997 13:37:07 +0200
Subject: Re: pointers &arrays[]
Mime-Version: 1.0




On 11/25/97 5:42:18 PM Peter Palotas  wrote:

>At 19.33 1997-11-24 -0500, you wrote:
>>array == &array[0]
>This is true.
>
>>array == &array
>This is NOT true. `&array' is a pointer to array, i.e. a pointer to the
>pointer of the first element in the array.
>
>>*array == array[0]
>This is also true.
>
>>*(array+n) == array[n]
>And so is this.
>
>
>>are all true given array[n].  In this case, sizeof(array) returns the
size
>>of the entire array, not array[0].  Are there other examples where this
>>pointer notation fails?
>
>I think that sizeof(array), would just return the size of a pointer, since
>that is what it is, and not the size of the actual array.
>
If it  was declared as an array for example like this:
     char array[100];
then  sizeof (array) == 100 * sizeof(char)
but if is just a pointer that is dereferenced with array operators ([ ])
then sizeof (array) is the size of a pointer variable.

Eyal.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019