UMBC CS 201, Fall 98
UMBC CMSC 201 & 201H Fall '98 CSEE | 201 | 201 F'98 | lectures | news | help

LValue and RValue

What do we mean by a variable?

In C, any expression that refers to a memory location capable of storing data is called an lvaue .

lvalues are things you can point to.

Where's the L come from?

A variable can appear on both the left hand side and the right hand side of an assignment operator, thus it has an lvalue and an rvalue.


     thisOne = thatOne;

thisOne is taken as the address of the variable whereas thatOne is taken as the value of the variable.

The lvalue must therefore yield a location, usually a reference to a variable and the rvalue can be any expression that yields a value.


     answer = (average + 5) * 2;

You can also have certain expressions as an lvalue such as when you obtain an array's element by subscripting.
     
     array[i] = i * i;


CSEE | 201 | 201 F'98 | lectures | news | help

Wednesday, 07-Oct-1998 21:34:39 EDT