Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert unsigned short into signed char in c language
How to convert unsigned short into signed char in c language
# include & ltstdio.h & gt

int main()

{

char ca

Unsigned character ucb

Unsigned short usc

ca = 128;

UCB = 128;

USC = ca+UCB;

printf("%d\n ",USC);

Usc = ca+(short) ucb

printf("%d\n ",USC);

Usc = (unsigned character) ca+UCB;;

printf("%d\n ",USC);

USC = ca+(char)UCB;

printf("%d\n ",USC);

getchar();

Return EXIT _ SUCCESS

}

The result is: 0,0,256,65280.

The most difficult question is whether you understand the data type conversion in C language.

There is a term called "integer lifting": there is such a conversion between arithmetic types, such as signed or unsigned char type, short type and Bit-field. Before doing arithmetic, they must do integer promotion before they can participate in the operation. For the conversion between other types, please refer to any C language book.