标签:c基本数据类型
先来张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;
}输出结果如下图:
本文出自 “7803002” 博客,请务必保留此出处http://7813002.blog.51cto.com/7803002/1539769
标签:c基本数据类型
原文地址:http://7813002.blog.51cto.com/7803002/1539769