2

Does "r- value" comes right of the assignment operator and "l- value" comes left of assignment operator or are they something more

0

1 Answer 1

1

l-value refers to memory location which identifies an object. l-value may appear as either left hand or right hand side of an assignment operator(=). l-value often represents as identifier.

Expressions referring to modifiable locations are called “modifiable l-values“. A modifiable l-value cannot have an array type, an incomplete type, or a type with the const attribute. For structures and unions to be modifiable lvalues, they must not have any members with the const attribute. The name of the identifier denotes a storage location, while the value of the variable is the value stored at that location.

An identifier is a modifiable lvalue if it refers to a memory location and if its type is arithmetic, structure, union, or pointer. For example, if ptr is a pointer to a storage region, then *ptr is a modifiable l-value that designates the storage region to which ptr points.


r-value refers to data value that is stored at some address in memory. A r-value is an expression that can’t have a value assigned to it which means r-value can appear on right but not on left hand side of an assignment operator(=).

https://www.geeksforgeeks.org/lvalue-and-rvalue-in-c-language/

Sign up to request clarification or add additional context in comments.

4 Comments

Does "==" as in relational operator can have l value or value
@user12153611 there's no assignment with ==, so you may have any value on either side
Ok got the answer
A reference in the C-Standard may help C11 Standard - 6.3.2.1 Lvalues, arrays, and function designators See Footnote (64) for historical note.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.