c语言自动导入数据类型,c语言数据类型

参考文章

数据类型一览表

算数类型(arithmetic type)

字符类型

signed char 有符号字符

unsigned char 无符号字符

char 字符(可以是 signed char 或 unsigned char,由实现定义)

// 除此之外,还定义了宽字符(c11):

1. wchar_t

2. char16_t

3. char32_t

整数类型

1. 短整形

short

signed short

short int

signed short int

// 等价于

short int

2. 无符号短整形

unsigned short

unsigned short int

// 等价于

unsigned short int

3. 整形

signed

int

signed int

// 等价于

int

4. 无符号整形

unsigned

unsigned int

// 等价于

unsigned int

5. 长整型

long

long int

signed long

signed long int

// 等价于

long int

6. 无符号长整型

unsigned long

unsigned long int

// 等价于

unsigned long int

7. long long int(c99,不懂该怎么称呼了...)

long long

long long int

signed long long

signed long long int

// 等价于

long long int

8. unsigned long long int(c99)

unsigned long long

unsigned long long int

// 等价于

unsigned long long int

数据模型

每种实现对数据类型的大小选择统称为 数据模型,以下四种是大家普遍接受的数据模型:

32 System

1. LP32 2/4/4,(int 16bit,long & pointer 32bit)

1. 仅出现在 win16 API 中

2. LP32 4/4/4,(int,long,pointer 32bit)

1. win32 API

2. 类 unix 系统(linux or mac)

64 System

3. LP64 4/4/8,(int & long 32big,pointer 64 bit)

4. LP64 4/8/8,(int 32 bit,long & pointer 64 bit)

其他模型非常罕见(几乎可以不用理会,实际就是无需理会)!举一个例子,数据模型 LP64 8/8/8(int & long & pointer 64 bit),这种数据模型只出现在早期的 unix 机器上

浮点类型

1. float 单精度浮点型 32bit(4byte)

2. double 双精度浮点型 64bit(8byte)

3. long double 扩展精密浮点型(需要机器支持) >=64 bit

如果使用了 complex.h,表示需要用到复杂的浮点数

以下写法都是有效的:

float _complex float complex

double _complex double complex

long double _complex long double complex

float _imaginary float imaginary

double _imaginary double imaginary

long double _imaginary long double imaginary

原子类型(atomic type),限定符

支持以下三种写法:

// p 是指向原子 const int 的指针

_Atomic const int * p1;

// 同上

const atomic_int * p2;

// 同上

const Atomic(int) * p3;

原子类型的对象是唯一不受数据竞争的对象,也就是说,它们可以由两个线程并发地修改,或者由另一个线程修改。

拥有以下四个相关属性:

1. 写入一致性(write-write-coherence)

2. 读取一致性(read-read-coherence)

3. 读写一致性(read-write-coherence)

4. 写读一致性(write-read-coherence)

具体解释参考官方文档:atomic type

目前的 visual studio 中不支持该类型

由 typedef 引入的说明符

// 声明 int_t 是 int 的别名

typedef int int_t

// 进阶

// char_t 是 char 的别名

// chart_p 是 char* 的别名

// fp 是 char(*)(void) 的别名

typedef char char_t, *char_p, (*fp)(void)

修饰符

const

// 常量不可改动

const int a = 10;

volatile

// 提醒计算机:

// a 变量可能会实时更新,不能缓存

// 这个一般多用在多线程场景下

volatile int a = 10;

restrict

特殊的常量

INFINITY 无穷

NaN 非数字

数值范围

如果需要准确的了解到数值的范围,请参阅(页面底部):各种类型对应的数值范围

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值