第15章 数据类型详解

1、数据类型

c中数据类型划分为四类:基本类型、构造类型、指针类型、空类类型。
其中基本类型可分为:数值类型和字符类型
1、数值类型
    1、短整型         short
    2、整型           int
    3、长整型         long
    4、单精度浮点型   float
    5、双精度浮点型   double
2、字符类型
    1、char
构造类型可分为:
    1、数组
    2、结构体   struct
    3、共用体   union
    4、枚举类型 enum
一些细节知识:
short int 简写为short
long int  简写为long
long long int 简写为long long
比如:
        long int s = 5;
        printf("%d\n",s);
编译通不过,报错如下:
l.c:5:9: 警告: 格式 ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat]
需改为:%ld
同理若是:long long int s = 5
则需要匹配为   %lld
 

2、数据类型默认情况

1、除了char型以外的这些整数类型如果不明确写signed或unsigned关键字都表示有符号数,这一点是C标准明确规定的,不是Implementation Defined。
2、除了char型在C标准中明确规定占一个字节之外,其它整数类型占几个字节都是Implementation Defined。

你可能感兴趣的:(第15章 数据类型详解)