DIGIT-ARC read-only archive · snapshot: July 23, 2026

L value reruired

9 posts · originally from https://geek.digit.in/community/threads/l-value-reruired.100349/

V
Virus Guy Original post #1
Oct 22, 2008 at 12:16 PM
Friends i am getting an ERROR : L value required for the below program at line no :3.

void main(){
int x=5;
++x++;
printf("X = %d ",x);
}

Can any one please explain me the concept of L value.
Sykora
Sykora #2
Oct 22, 2008 at 1:40 PM
What are you trying to do? ++x++ is invalid. You can only apply one of them at a time.

An lvalue is anything that can come on the left side of an '=' sign. When you use x++, it is interpreted as 'x = x + 1'. Here, x is an lvalue.

When you use ++x++, it tries '++x = x + 1', but ++x is not an lvalue, hence the error.
furious_gamer
Oct 22, 2008 at 3:05 PM
lol..... ++x++... Will u plz explain me whats the logic behind this....
And yes as the above member said LValue means the value in the left side.... So change ur code by break up ur logic as ++x,x++ so...
P
paroh #4
Oct 22, 2008 at 8:12 PM
++x++ lol
postfix x++
prefix ++xx
n2casey
n2casey #5
Oct 22, 2008 at 10:56 PM
lol..... ++x++... Will u plz explain me whats the logic behind this....
And yes as the above member said LValue means the value in the left side.... So change ur code by break up ur logic as ++x,x++ so...

++x++ lol
postfix x++
prefix ++xx

There is no point for lol, may b he has just started learning C...
V
Oct 23, 2008 at 1:32 PM
What are you trying to do? ++x++ is invalid. You can only apply one of them at a time.

An lvalue is anything that can come on the left side of an '=' sign. When you use x++, it is interpreted as 'x = x + 1'. Here, x is an lvalue.

When you use ++x++, it tries '++x = x + 1', but ++x is not an lvalue, hence the error.

why ++x is not an lvalue can you please tell me clearly
QwertyManiac
Oct 23, 2008 at 2:52 PM
I suppose that the lvalue requires itself to be an object/variable, and not a statement/expression.
Zangetsu
Oct 23, 2008 at 3:54 PM
Friends i am getting an ERROR : L value required for the below program at line no :3.

void main(){
int x=5;
++x++;
printf("X = %d ",x);
}

Can any one please explain me the concept of L value.

I think u wanna increment it 2 times i.e 1st pre-increment & then post increment...
ur syntax is wrong dats y u got lvalue required error...
use
++x;
x++;
instead of ++x++;

the compiler reads from left 2 right..so on 3rd line it first sees ur + sign & again
+ sign & then x so it thinks its a preincrement operation..but it also
sees other 2 + sign gets confused & coz the ++x results in a value 2 processing
error is there ....& 4 remaing 2 plus signs it needs a value 2 store them
hence the error