This is a discussion on Help to Resolve Error within the C and C++ forums, part of the Programming Talk category; I am getting error when I tried to compile my below simple program in C. #include <stdio.h> ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am getting error when I tried to compile my below simple program in C.
#include <stdio.h> main() { int a=5,b; b=a++++2; printf("a=%d b=%d",a,b); } I could not understand the reason to resolve the error. Kindly help me out. |
|
|||
|
Before resolving the error you must first understand what is Lvalue which is displayed in error message. Lvalue refers to the variable whose values can change and this is placed to the left of assignment operator. There is another variable called rvalue which is in contrast to the Lvalue. The value of rvalue cannot change and this is placed to the right of assignment operator.
Now coming to your program you have statement as b=a++++2; In the above a++++2 is expanded as compiler as a++ ++2 In this a++ is fine but ++2 is wrong since ++ cannot be applied to constants and so you have the error as Lvalue required in function main. So remove the constant and make that as a variable and your problem would be resolved. |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error Message | Rahulbatra | ASP | 1 | 05-24-2007 04:37 PM |
| web.config gives error if i store string that contin "&" character in appSettings | mahehs_k_anjani | Microsoft .NET | 2 | 09-06-2006 06:21 AM |
| Comp.Sys.Acorn.FAQ part 2 of 4 | Paul Vigay | Tech FAQ | 0 | 05-31-2004 09:00 PM |
| Apple II Csa2 FAQs: Error List, Part 8/25 | rubywand@swbell.net | Tech FAQ | 0 | 05-04-2004 10:01 AM |
| Comp.Sys.Acorn.FAQ part 2 of 4 | Paul Vigay | Tech FAQ | 0 | 04-30-2004 09:00 PM |