CrazyEngineers Archive
Old, but evergreen and popular discussions on CrazyEngineers, presented to you in read-only mode.
@tanvisharma • 14 May, 2012
can anybody give a clear explanation about 'r' and 'l' value error in c.....
@Anoop Kumar • 15 May, 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.

https://msdn.microsoft.com/en-us/library/bkbs2cds.aspx
@Ankita Katdare • 15 May, 2012 tanvisharma 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:
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.
@pratap singh, upendra • 25 May, 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 type
@pratap singh, upendra • 25 May, 2012 • 1 like 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 type
@tanvisharma • 28 May, 2012 thank you all 😀
@Aviskar • 31 May, 2012 can anybody tell me what is this pointer and how it is used in c++?
@amitabh1608 • 03 Jun, 2012 refer any c++ book
@Anthoni Raj • 04 Jun, 2012 • 1 like
tanvisharma 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:
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.

5.6k views

## Related Posts

@Satya Swaroop Dash · Nov 1, 2014

Samsung has been constantly criticised for its done-to-death plastic designs. Samsung fanatics find it difficult to distinguish between Galaxy Grand and Galaxy S IV from couple of feet away. Considering...
4.1k views

@Feather · May 29, 2012

can somebody please explain the difference between expansion and construction joint with simple example? what are its practical usages?
36.8k views

@eng_SaLoM · Apr 16, 2012

Hi how are u doing all,,, i want solution manual for sadiku elements of electromagnetics 5th edition,, i found one with odd answers ,, but i am looking for full...
4.2k views

@Kaustubh Katdare · Oct 31, 2012

How many of you know that the total amount of data generated on the Interent every day amounts to is equivalent to about 250 million DVDs aka one 'exabyte'. But...
10.8k views

@Ankita Katdare · Apr 22, 2014

Sony India has officially launched its latest Android 4.3 (Jelly Bean) running smartphone - the Sony Xperia M2 Dual in India at a price of Rs. 21,990. Powered by a...
6.9k views