int main(){ int x<3>=4,5,6; int *p=x; ns +1=p;/*compiler mirrors error saying lvalue forced as left operand that assignment*/ cout


When you have actually an assignment operator in a statement, the LHS that the operator must be other the language calls an lvalue. If the LHS the the operator does no evaluate to an lvalue, the value from the RHS can not be assigned come the LHS.

You are watching: Lvalue required as left operand of assignment

You cannot use:

10 = 20;since 10 does not evaluate come an lvalue.

You deserve to use:

int i;i = 20;since i does evaluate to an lvalue.

You cannot use:

int i;i + 1 = 20;since ns + 1 does not evaluate come an lvalue.

In her case, ns + 1 does not evaluate to an lavalue. Hence, you can not use

p + 1 = p;
improve this price
answer Oct 27 "15 at 18:01


R SahuR Sahu
198k1313 yellow badges138138 silver- badges253253 bronze badges
add a comment |
To assign, you must use p=p+1; rather of p+1=p;

int main(){ int x<3>=4,5,6; int *p=x; p=p+1; /*You just needed to move the terms around*/ cout
improve this price
answer Oct 27 "15 at 17:53


25k1515 yellow badges5858 silver badges7979 bronze title
include a comment |
Put simply, an lvalue is something that can show up on the left-hand side of an assignment, typically a variable or variety element.

So if you specify int *p, then p is one lvalue. P+1, which is a precious expression, is no an lvalue.

If you"re trying to include 1 come p, the correct syntax is:

p = p + 1;
boost this answer
answer Oct 27 "15 at 18:02


169k1818 yellow badges175175 silver badges220220 bronze badges
add a comment |
if you use an assignment operator yet use that in wrong means or in not correct place, then you"ll obtain this types of errors!

suppose if you type:p+1=p; you will obtain the error!!

you will obtain the exact same error for this:if(ch>="a" && ch="z")as you see deserve to see that ns i tried to assign in if() statement!!!how silly i am!!! right??ha haactually i forgot to provide less then( if(ch>="a" && chand gained the error!!

enhance this answer
answered Oct 24 "17 in ~ 13:46
1111 bronze argorial
include a comment |
It is simply a typo(I guess)-

p+=1;instead of ns +1=p; is required .

As name imply lvalue expression must be left-hand operand of the assignment operator.

enhance this price
reply Oct 27 "15 in ~ 17:58
16k22 yellow badges2222 silver- badges4040 bronze title
include a comment |

your Answer

Thanks because that contributing response to stack Overflow!

Please be sure to answer the question. Provide details and share her research!

But avoid

Asking for help, clarification, or responding to other answers.Making statements based on opinion; ago them up with recommendations or personal experience.

To find out more, view our tips on writing an excellent answers.

See more: Michael.B Jordan Nick Cannon, Michael B, Interchangeable Celebs

Draft saved
Draft discarded

Sign up or log in

authorize up making use of Google
sign up using Facebook
sign up utilizing Email and Password

Post as a guest

email Required, however never shown

Post as a guest


Required, but never shown

article Your answer Discard

By clicking “Post her Answer”, you agree to our regards to service, privacy policy and cookie policy

Not the price you're spring for? Browse various other questions tagged c++ pointers forced lvalue or asking your own question.

The Overflow Blog
Featured top top Meta
2 different weird errors v struct assignment
target C - Lvalue compelled as left operand the assignment
GCC error once compiling: "lvalue compelled as left operand of assignment" with role pointer
Overloading operator<> and also NOT obtaining "lvalue required as left operand the assignment" error
"lvalue forced as left operand that assignment" once using pointers in C
warm Network questions more hot concerns

inquiry feed
i ordered it to RSS
concern feed To subscribe to this RSS feed, copy and also paste this URL into your RSS reader.

ridge Overflow
stack Exchange Network
site design / logo © 2021 stack Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.9.17.40238

Stack Overflow works best with JavaScript allowed

your privacy

By clicking “Accept every cookies”, friend agree stack Exchange can store cookies on your maker and disclose information in accordance v our Cookie Policy.