Next: , Previous: , Up: Assignment Expressions   [Contents][Index]


7.2 Lvalues

An expression that identifies a memory space that holds a value is called an lvalue, because it is a location that can hold a value.

The standard kinds of lvalues are:

If an expression’s outermost operation is any other operator, that expression is not an lvalue. Thus, the variable x is an lvalue, but x + 0 is not, even though these two expressions compute the same value (assuming x is a number).

An array can be an lvalue (the rules above determine whether it is one), but using the array in an expression converts it automatically to a pointer to the zeroth element. The result of this conversion is not an lvalue. Thus, if the variable a is an array, you can’t use a by itself as the left operand of an assignment. But you can assign to an element of a, such as a[0]. That is an lvalue since a is an lvalue.