您的位置:首页 > 其它

C数据类型之基本类型

2014-08-14 10:19 99 查看
先来张C数据类型的图片,如下图




基本数据类型的长度,数据存储是以"字节"(Byte)为单位,数据传输是以"位"(bit)为单位,一位就代表一个0或1(二进制),一个字节(Byte)占8位(bit).
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
@autoreleasepool {
short int shortIntType = 1;
int intType = 2;
long longType = 3L;
float floatType = 4.1f;
double doubleType = 5;
char charType = 'A';

printf("size of short it is %lu Byte\n",sizeof(shortIntType));
printf("size of int is %lu Byte\n",sizeof(intType));
printf("size of long is %lu Byte\n",sizeof(longType));
printf("size of float is %lu Byte\n",sizeof(floatType));
printf("size of double is %lu Byte\n",sizeof(doubleType));
printf("size of char is %lu Byte\n",sizeof(charType));
}
return 0;
}
输出结果如下图:


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c 基本数据类型