c语言中各个类型的sizeof长度

#include <stdio.h>
int main()
{
    printf("\nA Char is %lu bytes"sizeofchar ));
    printf("\nAn int is %lu bytes"sizeofint ));
    printf("\nA short is %lu bytes"sizeofshort ));
    printf("\nA long is %lu bytes"sizeoflong ));
    printf("\nA long long is %lu bytes\n"sizeoflong long ));
    printf("\nAn unsigned Char is %lu bytes"sizeof( unsigned char ));
    printf("\nAn unsigned int is %lu bytes"sizeof( unsigned int));
    printf("\nAn unsigned short is %lu bytes"sizeof( unsigned short ));
    printf("\nAn unsigned long is %lu bytes"sizeof( unsigned long ));
    printf("\nAn unsigned long long is %lu bytes\n",sizeof( unsigned long long ));
    printf("\nfloat is %lu bytes"sizeoffloat ));
    printf("\nA double is %lu bytes\n"sizeofdouble ));
    printf("\nA long double is %lu bytes\n"sizeoflong double ));
return 0;
}
muhuacat@muhuacat:~/bin# gcc -o c c.c 
muhuacat@muhuacat:~/bin# ./c

A Char is 1 bytes
An int is 4 bytes
short is 2 bytes
long is 8 bytes
long long is 8 bytes

An unsigned Char is 1 bytes
An unsigned int is 4 bytes
An unsigned short is 2 bytes
An unsigned long is 8 bytes
An unsigned long long is 8 bytes

float is 4 bytes
double is 8 bytes

long double is 16 bytes

 

posted on 2016-05-11 15:33  木花猫  阅读(1077)  评论(0编辑  收藏  举报

导航