首页 > 代码库 > C语言里int,unsigned int,shor int...转换输出问题

C语言里int,unsigned int,shor int...转换输出问题

这问题,有时候是个困扰,抽空梳理一遍。

signed char->unsgned char:%c->%c 0->127(对应范围)

char->int:%c->%d->%c,‘A‘->65(可打印字符表对应)

short int->int:%d->%d,100->100(对应,反向操作若超出范围,循环读取对应)

short int->unsinged int:%u->%d,(对应,反向操作若超出范围,循环读取对应)

unsigned int->int:%u->%d,4294967295->2147483647(对应范围)

 

 

signed -128~127

unsigned char 0~127

char -128~127 (一般机器=signed char)

short int -32768~32767

unsigned short int 0~65535

int (signed int) -2147483648~2147483647

unsigned int 0~4294967295

 

C语言里int,unsigned int,shor int...转换输出问题