Mail Archives: cygwin/1997/11/24/05:45:34
> array == &array[0]
> array == &array
> *array == array[0]
> *(array+n) == array[n]
>
> 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?
> Lastly, is this pointer notation implementation dependent or is it part of
> the de facto standard?
I don't know about de facto standards for C; nowadays, there pretty much
aren't any, since there is a de jure standard, ISO C (IS 9981 if memory
serves). And the pointer/array equivalences you mentioned are required
by the standard.
The compiler can only make sizeof(array) equal to the size of the array
when in fact the compiler can see a complete definition of the array
in-scope. If you pass array as a parameter to a function, a sizeof()
expression in that function generally won't know how big the array
actually is.
Arrays are not first-class datatypes in C; most of the time an array of
type Foo has to be treated as a pointer to an element of type Foo.
Jason
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -