#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;
}
C语言 枚举(enum)、宏定义(#define)、结构体(struct)的一种联合应用
最新推荐文章于 2023-02-17 17:16:58 发布