C语言数据类型表
关键字 | 位长(字节) | 范围 | 格式化字符串 |
---|
char | 1 bytes | -128…127(或0…255,与体系结构相关) | %c | unsigned char | 1bytes | 0…255 | %c, %hhu | signed char | 1bytes | -128…127 | %c, %hhd, %hhi | int | 2bytes(16位系统) 或 4bytes | -32768…32767 或 -2147483648…2147483647 | %i, %d | unsigned int | 2bytes 或 4 bytes | 0…65535 或 0…4294967295 | %u | signed int | 2bytes 或 4bytes | -32768…32767 或 -2147483648…2147483647 | %i, %d | short int | 2bytes | -32768…32767 | %hi, %hd | unsigned short | 2 bytes | 0…65535 | %hu | signed short | 2bytes | -32768…32767 | %hi, %hd | long int | 4bytes 或 8bytes[6] | -2147483648…2147483647 或 -9223372036854775808…9223372036854775807 | %li, %ld | unsigned long | 4bytes 或 8 bytes | 0…4294967295 或 0…18446744073709551615 | %lu | signed long | 4 bytes或 8bytes | -2147483648…2147483647 或 -9223372036854775808…9223372036854775807 | %li, %ld | long long | 8bytes | -9223372036854775808…9223372036854775807 | %lli, %lld | unsigned long long | 8bytes | 0…18446744073709551615 | %llu | float | 4bytes | 2.939x10−38…3.403x10+38 (7 sf) | %f, %e, %g | double | 8bytes | 5.563x10−309…1.798x10+308 (15 sf) | %lf, %e, %g | long double | 10bytes或 16bytes | 7.065x10-9865…1.415x109864 (18 sf或33 sf) | %lf, %le, %lg |
|