C语言中的一些小知识(84)

前面加0b表示二进制

  加0x表示十六进制

  数字前加0表示八进制

  ‘ ‘ //ASCII值是63

  ‘\077’ //是8进制表示’ ‘,0可以省略,因为C,C++规定不允许使用斜杠加10进制数来表示字符

  ‘\0x3F’ //是16进制表示’ ‘

  
关键字 位长(字节) 范围 格式化字符串
char 1 -128..127(或0..255,与体系结构相关) %c

unsigned char 1 0..255

signed char 1 -128..127

int 2(16位系统)或4 -32768..32767 或-2147483648..2147483647 %i, %d

unsigned int 2或4 0..65535 或0..4294967295 %u

signed int 2 或4 -32768..32767 或-2147483648..2147483647 %i, %d

short int 2 -32768..32767 %hi

unsigned short 2 0..65535 %hu

signed short 2 -32768..32767 long int 4 或8[3] -2147483648..2147483647或-9223372036854775808..9223372036854775807 %li, %ld

unsigned long 4 或8 0..4294967295 或0..18446744073709551615 %lu

signed long 4 或8 -2147483648..2147483647或-9223372036854775808..9223372036854775807

long long 8 -9223372036854775808..9223372036854775807 %lli

unsigned long long 8 0..18446744073709551615 %llu

float 4 3.4x10 38..3.4x10+38 (7 sf) %f, %e, %g

double 8 1.7x10 308..1.7x10+308 (15 sf) %f, %e, %g

long double 8 或以上 编译器相关 %Lf, %Le, %Lg

// //