raghu said:
> #include<stdio.h>
> int main(void)
> {
> int a=1;
> int b=2;
> int c=0;
> c=(a+b)++;
> printf("%d",c);
> return 0;
> }
>
> For the above program I got the error as Lvalue required.
That's right, yes. ++ affects the value of an object. Arbitrary expressions
won't do.
> Can anyone please explain why the error is and how to eliminate it .
++ increases the value of an object by 1. (a+b) is not an object. To
eliminate the error, remove the ++:
#include<stdio.h>
int main(void)
{
int a = 1;
int b = 2;
int c = 0;
c = a + b;
printf("%d", c);
return 0;
}
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: normal service will be restored as soon as possible. Please do not
adjust your email clients.