what is r value, l value error in c??
can anybody give a clear explanation about 'r' and 'l' value error in c.....
Replies
-
Anoop KumarI 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-# -
Ankita Katdare#-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. -
pratap singh, upendraduring 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, upendraduring 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 -
tanvisharmathank you all 😀
-
Aviskarcan anybody tell me what is this pointer and how it is used in c++?
-
amitabh1608refer any c++ book
-
Anthoni RajAbraKaDabra#-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...
You are reading an archived discussion.
Related Posts
https://view.email.globalspec.com/?j...11175&jb=ffcf14&ju=fe2015797d600274751c72&r=0
https://news.nationalgeographic.com/...ggest-crocodile-early-humans-science-animals/
my name is anurag and I'm doing B.Tech in Electronics and communication.
I stay in Delhi and I'm pursuing my B.Tech degree in Kerala.
I like to listen songs and...
Can someone give me a bird's eye view of the MVC (Model-View-Controller) architecture typically used in software design? I've been looking for simpler definitions online but looks like people need...
I think we discussed this before but it won't hurt to repeat. Lot of people use the word 'softwares' to describe multiple number of software products / suits installed on...