#include<stdio.h> //line 1
#include<conio.h> //line 2
void main() //line 3
{ //line 4
int a=6,g=7,b=3; //line 5
clrscr(); //line 6
printf("%d",a>?g=a:g=b); //line 7
getch(); //line 8
}
Case 1: before saving the file
This will give an error at line no 7 'Lvalue required'. But when I compile no error will come and after running, it produced output 3.
Case 2 : after saving the file
And when we save this file then we get an error "Lvalue required'.
sorry for my mistake and Write question here
#include<stdio.h> //line 1
#include<conio.h> //line 2
void main() //line 3
{ //line 4
int a=6,g=7,b=3; //line 5
clrscr(); //line 6
printf("%d",a>b?g=a:g=b); //line 7**
getch(); //line 8
}
Case 1: before saving the file
This will give an error at line no 7 'Lvalue required'. But when I compile no error will come and after running, it produced output 3.
Case 2 : after saving the file
And when we save this file then we get an error "Lvalue required'.
"Lvalue required" means you cannot assign a value to something that has no place in memory. Basically you need a variable to be able to assign a value.
in your particular case I would remove a>g=a:g=b
and replace it with something more comprehensible, because in the current state nobody (including you and your compiler) has any slightest idea what that's supposed to be.
this : printf("%d",a>g=a:g=b); makes no sense. I cant tell if you tying to make a conditional in it which you shouldn't ever do especially for something so simple.
You should read into how printf works becuase either your not understanding what is need which is something like this:
int a = 1;
printf("%d",a);
or you meant to use somthing else but I have never seen a syntax like your doing before here a>g=a:g=b.
来源:https://stackoverflow.com/questions/13524104/what-does-lvalue-required-mean-in-a-c-compiler-error