We Are Going To Discuss About **lvalue required as left operand of assignment error when using C++**. So lets Start this Article.

## lvalue required as left operand of assignment error when using C++

**How to solve lvalue required as left operand of assignment error when using C++**

When you have an assignment operator in a statement, the LHS of the operator must be something the language calls an *lvalue*. If the LHS of the operator does not evaluate to an *lvalue*, the value from the RHS cannot be assigned to the LHS.

You cannot use:`10 = 20;`

since `10`

does not evaluate to an *lvalue*.

You can use:`int i; i = 20;`

since `i`

does evaluate to an *lvalue*.

You cannot use:`int i; i + 1 = 20;`

since `i + 1`

does not evaluate to an *lvalue*.

In your case, `p + 1`

does not evaluate to an *lavalue*. Hence, you cannot use`p + 1 = p;`

**lvalue required as left operand of assignment error when using C++**

When you have an assignment operator in a statement, the LHS of the operator must be something the language calls an *lvalue*. If the LHS of the operator does not evaluate to an *lvalue*, the value from the RHS cannot be assigned to the LHS.

You cannot use:`10 = 20;`

since `10`

does not evaluate to an *lvalue*.

You can use:`int i; i = 20;`

since `i`

does evaluate to an *lvalue*.

You cannot use:`int i; i + 1 = 20;`

since `i + 1`

does not evaluate to an *lvalue*.

In your case, `p + 1`

does not evaluate to an *lavalue*. Hence, you cannot use`p + 1 = p;`

## Solution 1

When you have an assignment operator in a statement, the LHS of the operator must be something the language calls an *lvalue*. If the LHS of the operator does not evaluate to an *lvalue*, the value from the RHS cannot be assigned to the LHS.

You cannot use:

```
10 = 20;
```

since `10`

does not evaluate to an *lvalue*.

You can use:

```
int i;
i = 20;
```

since `i`

does evaluate to an *lvalue*.

You cannot use:

```
int i;
i + 1 = 20;
```

since `i + 1`

does not evaluate to an *lvalue*.

In your case, `p + 1`

does not evaluate to an *lavalue*. Hence, you cannot use

```
p + 1 = p;
```

Original Author R Sahu Of This Content

## Solution 2

To assign, you should use `p=p+1;`

instead of `p+1=p;`

```
int main()
{
int x[3]={4,5,6};
int *p=x;
p=p+1; /*You just needed to switch the terms around*/
cout<<p<<endl;
getch();
}
```

Original Author jh314 Of This Content

## Solution 3

Put simply, an lvalue is something that can appear on the left-hand side of an assignment, typically a variable or array element.

So if you define `int *p`

, then `p`

is an lvalue. `p+1`

, which is a valid expression, is not an lvalue.

If you’re trying to add 1 to `p`

, the correct syntax is:

```
p = p + 1;
```

Original Author dbush Of This Content

## Solution 4

if you use an assignment operator but use it in wrong way or in wrong place,

then you’ll get this types of errors!

suppose if you type:

p+1=p; you will get the error!!

you will get the same error for this:

if(ch>=’a’ && **ch=’z’**)

as you see can see that I i tried to assign in if() statement!!!

how silly I am!!! right??

ha ha

actually i forgot to give less then(<) sign

if(ch>=’a’ && ch<=’z’)

and got the error!!

Original Author Rimon Of This Content

## Conclusion

So This is all About **This Tutorial.** Hope This Tutorial Helped You. Thank You.