C语言-枚举

预处理指令#define

1 #define MON  1
2 #define TUE   2
3 #define WED  3
4 #define THU   4
5 #define FRI    5
6 #define SAT   6
7 #define SUN   7

枚举类型的定义

方法一:

//枚举类型的定义
enum Day
{
    MON = 1,
    TUE = 2,
    WED = 3,
    THU = 4,
    FRI = 5,
    SAT = 6,
    SUN = 7
}

//变量声明
enum Day today;

方法2:

 1 //枚举类型的定义
 2 typedef enum day
 3 {
 4     MON = 1,
 5     TUE = 2,
 6     WED = 3,
 7     THU = 4,
 8     FRI = 5,
 9     SAT = 6,
10     SUN = 7
11 }
12 
13 //变量声明
14 day today;

 

posted @ 2015-05-14 20:48  guojunzi  阅读(158)  评论(0编辑  收藏  举报