Int main ()
{
unsigned char i;
I=5;
Printf (" % d \ n ", ~ I);
return 0;
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#include
Int main ()
{
unsigned char i;
I=5;
I=~ I;
Printf (" % d \ n ", I);
return 0;
}
The result of the two output why different?
CodePudding user response:
In the middle of this mixed with type conversion, such as I=~ I; ~ I will take the first type to int, so ~ I result is - 251 (highest level for the sign bit int type);I=~ I; Give I have - 251 assignment type int to unsigned char (eventually converted to an unsigned char),