|
|
1.1 root 1:
2:
3: lvalue Definition lvalue
4:
5:
6:
7:
8: An lvalue is an expression that designates a region of storage.
9: The name comes from the assignment expression e1=e2;, in which
10: the left operand must be an lvalue.
11:
12: An identifier has both an lvalue (its address) and an rvalue (its
13: contents). Some C operators require lvalue operands; for ex-
14: ample, the left operand of an assignment statement must be an
15: lvalue. Some operators give lvalue results; for example, if e is
16: a pointer expression, *e is an lvalue that designates the object
17: to which e points.
18:
19: A _v_a_r_i_a_b_l_e can be used as an lvalue, whereas a constant cannot.
20: For example, you cannot say
21:
22:
23: 6 = (foo+bar);
24:
25:
26: A pointer is a variable, and can be manipulated within limits.
27: An array name, however, is a constant and cannot be altered
28: legally. Thus, the code
29:
30:
31: int foo[10];
32: int *bar;
33: foo = bar;
34:
35:
36: will generate an error message when you attempt to compile it,
37: whereas
38:
39:
40: int foo[10];
41: int *bar;
42: bar = foo;
43:
44:
45: will not.
46:
47: The following example shows the use of both an lvalue and a
48: rvalue:
49:
50:
51: int i, *ip;
52:
53: ip = &i; /* ip is an lvalue, i and &i are rvalues */
54: i = 3; /* i is an lvalue, 3 is an rvalue */
55: *ip = 4; /* *ip is an lvalue, 4 is an rvalue */
56:
57:
58: ***** See Also *****
59:
60: definitions, rvalue
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.