c语言中各个类型的sizeof长度
#include <stdio.h>
int main()
{
printf("\nA Char is %lu bytes", sizeof( char ));
printf("\nAn int is %lu bytes", sizeof( int ));
printf("\nA short is %lu bytes", sizeof( short ));
printf("\nA long is %lu bytes", sizeof( long ));
printf("\nA long long is %lu bytes\n", sizeof( long 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", sizeof( float ));
printf("\nA double is %lu bytes\n", sizeof( double ));
printf("\nA long double is %lu bytes\n", sizeof( long double ));
return 0;
}
int main()
{
printf("\nA Char is %lu bytes", sizeof( char ));
printf("\nAn int is %lu bytes", sizeof( int ));
printf("\nA short is %lu bytes", sizeof( short ));
printf("\nA long is %lu bytes", sizeof( long ));
printf("\nA long long is %lu bytes\n", sizeof( long 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", sizeof( float ));
printf("\nA double is %lu bytes\n", sizeof( double ));
printf("\nA long double is %lu bytes\n", sizeof( long 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
A short is 2 bytes
A long is 8 bytes
A 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
A double is 8 bytes
A long double is 16 bytes
muhuacat@muhuacat:~/bin# ./c
A Char is 1 bytes
An int is 4 bytes
A short is 2 bytes
A long is 8 bytes
A 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
A double is 8 bytes
A long double is 16 bytes