-
can anybody give a clear explanation about 'r' and 'l' value error in c.....0
-
Member • May 14, 2012
I am not in C progamming any more but I found this, it might help you.
Suppose the code is
int i;
i=5;
here i is lvalue and 5 is Rvalue.
the code 5=i;
generateserror lvalue required.
#-Link-Snipped-#Are you sure? This action cannot be undone. -
Administrator • May 15, 2012
#-Link-Snipped-# Did you get an error in a specific program? We can be of better help if you share the exact problem with us.
The difference between an l-value and an r-value can be used for eliminating a common bug.
Programmers sometimes wrongly replace the = operator for the == operator.
This reverses the order of an equality expression, placing the r-value on the left, like this:
if (0==x) //instead of x==0
When placing the r-value on the left, mistyping the == operator as the = operator triggers a compilation error:
if (0=x) // error: "L-value required"
Although this isn't the most intelligible error message, it certainly catches the bug.Are you sure? This action cannot be undone. -
Member • May 25, 2012
during the process of assignment of value to the variable whichever variable comes on the left hand side of equals sign is the lvalue meaning left_value. On the other hand the variable or a value appearing on the right hand side of equals sign is the rvalue meaning right_value.
The concept of rvalue and lvalue was just a theoretical notion that came into being on account of confusion that arose between = and == operators.
for example, consider
a = 9;
a = b;
in the first case the value of a is assigned to be 9. this implies lvalue is a and rvalue is 9
in the second case lvalue is a while rvalue is another variable b.
Note that lvalue should necessarily be a variable. On the other hand rvalue can be a varaible or a constant of appropriate data typeAre you sure? This action cannot be undone. -
Member • May 25, 2012
during the process of assignment of value to the variable whichever variable comes on the left hand side of equals sign is the lvalue meaning left_value. On the other hand the variable or a value appearing on the right hand side of equals sign is the rvalue meaning right_value.
The concept of rvalue and lvalue was just a theoretical notion that came into being on account of confusion that arose between = and == operators.
for example, consider
a = 9;
a = b;
in the first case the value of a is assigned to be 9. this implies lvalue is a and rvalue is 9
in the second case lvalue is a while rvalue is another variable b.
Note that lvalue should necessarily be a variable. On the other hand rvalue can be a varaible or a constant of appropriate data typeAre you sure? This action cannot be undone. -
Member • May 28, 2012
thank you all 😀Are you sure? This action cannot be undone. -
Member • May 31, 2012
can anybody tell me what is this pointer and how it is used in c++?Are you sure? This action cannot be undone. -
Member • Jun 3, 2012
refer any c++ bookAre you sure? This action cannot be undone. -
Member • Jun 3, 2012
AbraKaDabra#-Link-Snipped-# Did you get an error in a specific program? We can be of better help if you share the exact problem with us.
The difference between an l-value and an r-value can be used for eliminating a common bug.
Programmers sometimes wrongly replace the = operator for the == operator.
This reverses the order of an equality expression, placing the r-value on the left, like this:
if (0==x) //instead of x==0
When placing the r-value on the left, mistyping the == operator as the = operator triggers a compilation error:
if (0=x) // error: "L-value required"
Although this isn't the most intelligible error message, it certainly catches the bug.
Your answer is good...Are you sure? This action cannot be undone.