This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: pointers &arrays[]

> 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.

For help on using this list (especially unsubscribing), send a message to
"" with one line of text: "help".

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]