if (mychar = black, Black)
cout << "Did you know black is a mixture of all colors?";
I think there's your problem.
First of all, you're assigning black to myChar.
This will return true since that would return the new value of myChar and cast it to bool, which will always be true.
Regarding the comma operator in C++:
the comma operator (represented by the token ,) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).
In this case, it functions as an "Ok, fuck that last statement. [the second operand] is going to be returned".
Since a char cast to bool is always true (1), we're just doing an if (true) statement (do they have a name?).
So what you're basically doing:
Assigning the value of Black to mychar in an if statement that is always going yield true.
To compare stuff we use "==". If you're trying to check whether mychar is equal to black AND Black, do something like this: "if (mychar == black && mychar == Black) {".
Don't know if this is the problem you're having, but this is an issue anyway.
P.S: I know next to nothing about C++ (though I do know a little bit of C).
P.S.S: Your code is truly horrible (no offence).
I've improved (more like rewritten but nevermind) your code.
Now it accepts any case, and doesn't throw a hissy fit when the user enters some trailing/leading spaces.
Here's my fix (although I've had to improvise a little):
using namespace std;
#include <iostream>
#include <string>
#include <algorithm> // For the uppercase function. Maybe including an entire file for a single function is a bit overkill.
int main(int argc, char** argv) {
string preferredColour;
cout << "Do you prefer black or white? ";
cin >> preferredColour;
std::transform(preferredColour.begin(), preferredColour.end(),
preferredColour.begin(), ::toupper); // Convert the input to uppercase.
if (preferredColour.find("BLACK") != -1) {
cout << "Did you know black is a mixture of all colors?";
} else if (preferredColour.find("WHITE") != -1) {
cout << "White is nice looking.";
} else {
cout << " That is not a valid response.";
}
// _getch();
return 0;
}