c语言中输出各种数据类型的长度
c语言中输出各种数据类型的长度:
[root@PC1 test]# ls test.c [root@PC1 test]# cat test.c ## 测试程序 #include <stdio.h> int main(void) { printf("size of char: %u\n", (unsigned)sizeof(char)); printf("size of signed char: %u\n", (unsigned)sizeof(signed char)); printf("size of unsigned char: %u\n", (unsigned)sizeof(unsigned char)); puts("-----------------------------------------------------------"); printf("size of signed int: %u\n", (unsigned)sizeof(signed int)); printf("size of unsigned int: %u\n", (unsigned)sizeof(unsigned int)); puts("-----------------------------------------------------------"); printf("size of float: %u\n", (unsigned)sizeof(float)); printf("size of double: %u\n", (unsigned)sizeof(double)); printf("size of long double: %u\n", (unsigned)sizeof(long double)); return 0; } [root@PC1 test]# gcc test.c -o kkk ## 编译 [root@PC1 test]# ls kkk test.c [root@PC1 test]# ./kkk ## 测试 size of char: 1 size of signed char: 1 size of unsigned char: 1 ----------------------------------------------------------- size of signed int: 4 size of unsigned int: 4 ----------------------------------------------------------- size of float: 4 size of double: 8 size of long double: 16
。