What does non-lvalue in assignment error mean? How should it be fixed. I can't find a useful solution on the internet and any help would be greatly appreciated. Thank you!
#include <iostream>
usingnamespace std;
int main ()
{
//Ask for type of piece and position
cout << "Please enter P for Pawn, N for Knight, B for Bishop, R for Rook, Q for Queen and K for King." << endl;
char piece;
cin >> piece;
char y1;
int x1;
cout << "Enter the position of the piece, e.g. a7" << endl;
cin >> y1 >> x1;
//Final Position
char y2;
int x2;
cout << "Enter the final position." << endl;
cin >> y2 >> x2;
//Checking for validity
if (piece = "P" && y1 == y1 and x1 = x1 + 1)
cout << "The move is valid." << endl;
else
cout << "The move is invalid." << endl;
return 0;
}
What if I wanted to check what the entered piece was? Considering that piece = "P" or piece == "P", piece = P or piece == P wouldn't work, what should I write to access the type of piece?