sizeof() confusion
Chris Torek
chris at mimsy.umd.edu
Wed Nov 7 15:13:54 AEST 1990
In article <58808 at microsoft.UUCP> dans at microsoft.UUCP (Dan SPALDING) writes:
>In C, the base of an array is synonomous with a pointer to an element (the
>base element) of that array.
Not exactly. A precise definition is:
Given an object of type `array N of T' placed in a value context, a
C system must produce a value of type `pointer to T' which points
to the first (0th) element of that array.
`Array' and `pointer' are completely different, but one happens to be
converted to the other IN VALUE CONTEXTS. (A `value context' is any
place where you need the value of an expression. Thus, given
a = b;
`b' is in a value context, but `a' is not, because this puts the value
of b into a, but says nothing about the value of a.) C happens to have
about three contexts which are not value contexts: declarations, left
hand side of assignment operators (including `i' in `++i' and `i++'),
and following `sizeof'.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain: chris at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list