基本类型
整型
类型 | 关键字 | 变量声明 |
基本整型 | int | int a; |
长整型 | long | long int a;/long a; |
长长整型 | long long | long long int a;/long long a; |
短整型 | short | short int a;/short a; |
无符号整型 | unsigned | unsigned int a; unsigned long b; unsigned short c; |
实型(浮点型)
分类 | 关键字 | 变量声明 |
单精度实型 | float | float a; |
双精度实型 | double | double a; |
长双精度实型 | long double | long double a; |
字符型
字符型 | char | char a; |
枚举类型
枚举类型 | enum | enum response{no,yes,none} enum response answer; |
构造类型
数组 | - | int score[10]; char num[20]; |
结构体 | struct | struct date { int year; int day; }; struct date d; |
共用体 | union | union { int single; char spouseName[10]; struct date divorcedDay; }married; |
指针类型
指针类型 | - | int *ptr; char pStr; |
无类型
无类型 | void | void Sort(ont array[ ],int n); void*malloc(unsinged int size); |
定于整型变量时,只要不指定为无符号型,其类型就是有符号型,而signed通常不写