Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - In c language, enter C 1 = 187 and C2 = 198 in the char type. Why output c1=-59 and C2 =-58?
In c language, enter C 1 = 187 and C2 = 198 in the char type. Why output c1=-59 and C2 =-58?
Char type is a single-byte signed integer, which can only represent the range from+127 to-128.

197 and 198 exceed 127, which are regarded as complements (negative numbers).

If you use unsigned characters, you can use +255.

Unsigned characters c 1, C2;

c 1 = 197;

C2 = 198;

printf("c 1=%d,c2=%d\n ",c 1,C2);

This will not print negative values.