#include <stdio.h>
#include <string.h>
/*
#define Empty 0
#define Black 1
#define White 2
*/
enum ChessStatus //枚举类型
{
//成员不定定义变量,是写标示符
//默认从0开始,后一个比前一个大1
Empty, Black=1, White //枚举成员,枚举常量
};
int main()
{
//定义枚举变量
enum ChessStatus flag;
flag = Black;
printf("%d, %d\n", flag, Empty);
enum ChessStatus a[8][8];
memset(a, Empty, sizeof(a));
a[0][0] = Black;
a[0][1] = White;
return 0;
}
#include <stdio.h>
//#include <stdbool.h> //bool
enum _bool
{
false,
true
};
//typedef改类型名
typedef enum _bool bool;
int main()
{
bool flag;
flag = true;
flag = false;
return 0;
}
typedef struct Student
{
int a;
}Stu;
typedef struct Student S;
S obj;
Stu tmp;
typedef enum BOOL
{
FALSE,
TRUE
}BOOL;
int main()
{
//作用:给一个已存在的类型改名,不能新建类型
//1、把一个复杂的名字改为简单点
typedef int int64; //有分号
int64 a;
//2、代码移植
BOOL a = TRUE; //FLASE
//3、封装类型
return 0;
}