When I write the code
string s="000000";
string d="111111";
int x=(int)s[0]&(int)d[0];
char y= (char)x;
cout <<y << endl;
It works perfectly well and gives me the answer 0.
However, if I replace "&" by "^" (XOR) in the above code, the output given to me is just blank.
Why does this happen?
Note-
- I tried to replace
(int)s[0]^(int)d[0]
by((int)s[0]+(int)d[0])%2
but nothing changed in the result. I tried to introduce another variable to see if that solves the problem. But again nothing changed.
string s="000000"; string d="111111"; int x=(int)s[0]^(int)d[0]; int z=x; char y= (char)z; cout <<y << endl;