hello, im newbie here and also newbie in c++. I have a problem with char data type. I try writing the code input character 'D', 'd', 'R' and 'r'. if input are correct, the output will be 'OK' but turn out, even I give input other character, still give the output 'OK'. anyone can help me resolve the problem?
this is my code;
#include <iostream>
using namespace std;
int main () {
char choice ;
choice = 'D', 'R', 'd', 'r';
cout << "Insert choice: ";
cin >> choice;
if ( choice == 'D' || 'd' || 'R' || 'r' ) {
cout << "OK!" << endl;
}
else
cout << "Nub!" << endl;
return 0;
}
p/s: im using mingw g++ compiler