CrazyEngineers
  • what is r value, l value error in c??

    tanvisharma

    Member

    Updated: Oct 26, 2024
    Views: 2.4K
    can anybody give a clear explanation about 'r' and 'l' value error in c.....
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Anoop Kumar

    MemberMay 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.
    Cancel
  • Ankita Katdare

    AdministratorMay 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.
    Cancel
  • pratap singh, upendra

    MemberMay 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 type
    Are you sure? This action cannot be undone.
    Cancel
  • pratap singh, upendra

    MemberMay 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 type
    Are you sure? This action cannot be undone.
    Cancel
  • tanvisharma

    MemberMay 28, 2012

    thank you all 😀
    Are you sure? This action cannot be undone.
    Cancel
  • Aviskar

    MemberMay 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.
    Cancel
  • amitabh1608

    MemberJun 3, 2012

    refer any c++ book
    Are you sure? This action cannot be undone.
    Cancel
  • Anthoni Raj

    MemberJun 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.
    Cancel
Home Channels Search Login Register