What happens when you compare a char against an integer literal?
For example,
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
signed char c1 = 150;
if (c1 < 150)
cout << "Less than 150.\n";
else
cout << "Not less than 150.\n";
if (static_cast<unsigned char>(c1) < 150)
cout << "Less than 150.\n";
else
cout << "Not less than 150\n";
return 0;
}
VC++6.0 outputs "Less than 150.\nNot less than 150\n". I understand why
this would happen, but my question is, is this right? This disturbs me
because sometimes I want to read bytes in from a file and I'd like to
think that I could compare them against a hex literal. What should I
do?
Zach