C语言 枚举(enum)、宏定义(#define)、结构体(struct)的一种联合应用
程序员文章站
2022-06-10 10:50:11
...
#include <stdio.h>
typedef enum ENUMDATE
{
first=0x01,
second=0x02,
third=0x03
}enumdate;
//宏跨行,需要用续行符
#define DATEDE \
{ \
first, \
second, \
third \
} \
typedef struct DATE
{
char first;
char second;
char third;
}date;
int main()
{
date init = DATEDE;
printf("init.first=%d\r\n",init.first);
printf("init.second=%d\r\n",init.second);
printf("init.third=%d\r\n",init.third);
return 0;
}