I'm writing a c++ program in visual studio that reads lines from a file and performs the bitwise operator indicated by the file line. For some reason when I read in the file the program gives me wrong answers when using the & operator but not the >> operator. Also the final line in the file gets read twice, can anyone point out the problem?
void PrintOut(string bitwise_operator, int binNum1, int binNum2, int binNum3)
{
cout << "Applying the bitwise operator " << bitwise_operator
<< " to the following"<< "\n";
PrintBinary(binNum1);
PrintBinary(binNum2);
If you tried others in that ladder if system you have you would only find they all don't work because of that simple error. The way you had it it doesn't test expression against both strings, it assumes that one of those will always be true.
I don't see any problems with the math except the fact that the ifs are preventing something from happpening.