assigning 128 to char variable in c
问题 The output comes to be the 32-bit 2's complement of 128 that is 4294967168. How? #include <stdio.h> int main() { char a; a=128; if(a==-128) { printf("%u\n",a); } return 0; } 回答1: Compiling your code with warnings turned on gives: warning: overflow in conversion from 'int' to 'char' changes value from '128' to '-128' [-Woverflow] which tell you that the assignment a=128; isn't well defined on your plat form. The standard say: 6.3.1.3 Signed and unsigned integers 1 When a value with integer