c++ - Cannot compile, Lvalue required, in function main -


i want compile this, gives me error, change quotes, there error in header file, please let me know

#include<iostream.h> #include<conio.h>   void main() { char st[20];  cin>>st;   cout<<st<<endl;  if (st = 'a') cout<<"this a";   if (st = 'b') cout<<"this b";  getch(); } 

if (st = 'a') if (st = 'b') 

in both above lines l-value(left value) 'st' point beginning of array , address cannot changed. that's why error l-value in compilation. change if conditions equality(==) operator instead of assignment(=) , dereference st value in beginning.

if (*st == 'a') if (*st == 'b') 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -