c - Exception to array not decaying into a pointer? -


i have seen in many posts "in of cases array names decay pointers".
can know in cases/expressions array name doesn't decay pointers first elements?

sure.

in c99 there 3 fundamental cases, namely:

  1. when it's argument of & (address-of) operator.

  2. when it's argument of sizeof operator.

  3. when it's string literal of type char [n + 1] or wide string literal of type wchar_t [n + 1] (n length of string) used initialize array, in char str[] = "foo"; or wchar_t wstr[] = l"foo";.

furthermore, in c11, newly introduced alignof operator doesn't let array argument decay pointer either.

in c++, there additional rules, example, when it's passed reference.


Comments