Why does a casted char c
stored in an int
not be the same as the original char
?
I have looked all over for an explanation and I can't seem to be able to store a char
in an int
and be able to compare it to another int
.
#include <iostream>
using namespace std;
int main() {
char c = 255;
int x = (int)c;
cout << (x == 255) << endl;
return 0;
}
This outputs 0
. Why?