Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 22-10-2008, 12:16 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: May 2008
Posts: 42
Default L value reruired


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.
Virus Guy is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 22-10-2008, 01:40 PM   #2 (permalink)
I see right through you.
 
Sykora's Avatar
 
Join Date: Sep 2005
Location: Chennai
Posts: 597
Default Re: L value reruired

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.
__________________
I didn't make the world, I only try to live in it.
http://lucentbeing.com
-- Sykora --
Sykora is offline  
Old 22-10-2008, 03:05 PM   #3 (permalink)
Excessive happiness
 
furious_gamer's Avatar
 
Join Date: Jun 2008
Location: Bangalore
Posts: 2,974
Default Re: L value reruired

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...
__________________
My First Android phone : Samsung Galaxy SL i9003 - Rooted & Gingerbread XXKPQ
Updated : superteekz_V2 ROM for XXKPQ.

PS Request
furious_gamer is offline  
Old 22-10-2008, 08:12 PM   #4 (permalink)
Alpha Geek
 
paroh's Avatar
 
Join Date: Jul 2008
Posts: 781
Default Re: L value reruired

++x++ lol
postfix x++
prefix ++xx
paroh is offline  
Old 22-10-2008, 10:56 PM   #5 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Default Re: L value reruired

Quote:
Originally Posted by rajkumar_pb View Post
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...
Quote:
Originally Posted by paroh View Post
++x++ lol
postfix x++
prefix ++xx
There is no point for lol, may b he has just started learning C...
__________________
Minds are like Parachutes :arrow: They work best when open
n2casey is offline  
Old 23-10-2008, 01:32 PM   #6 (permalink)
Right Off the Assembly Line
 
Join Date: May 2008
Posts: 42
Default Re: L value reruired

Quote:
Originally Posted by Sykora View Post
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
Virus Guy is offline  
Old 23-10-2008, 02:52 PM   #7 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: L value reruired

I suppose that the lvalue requires itself to be an object/variable, and not a statement/expression.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 23-10-2008, 03:54 PM   #8 (permalink)
Fullbring
 
Zangetsu's Avatar
 
Join Date: Jan 2008
Location: Soul Society
Posts: 5,523
Default Re: L value reruired

Quote:
Originally Posted by Virus Guy View Post
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
__________________
I'm the One you've been Waiting for...
Zangetsu is offline  
Old 23-10-2008, 06:38 PM   #9 (permalink)
Console Junkie
 
aditya.shevade's Avatar
 
Join Date: Jun 2006
Location: USA
Posts: 991
Default Re: L value reruired

while (--i) i--;
__________________
--- Console Junkie
aditya.shevade is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by topgear
- by Charan

Advertisement




All times are GMT +5.5. The time now is 05:54 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2