728x90
반응형
1, main.c
#include "test.h"
void main(void)
{
number number1;
number1 = key2;
printf("test numer1 %d \r\n", number1);
printf("test key1%d \r\n", key1);
printf("test key2%d \r\n", key2);
}
2. test.h
#include <stdio.h>
typedef enum {
key1 = 0,
key2,
key3
}number;
3. 결과
4. // 주석
이렇게 쓰면 장점이 1. 따로 변수 설정 안해도 되요~ 2. 구조체와 enum 의 장점을 다 쓸수 있어요~ |
728x90
반응형
'공부 > C언어' 카테고리의 다른 글
15.배열 초기화 하기 3가지 방법 (0) | 2018.10.19 |
---|---|
14. 구조체 기본 (0) | 2018.10.18 |
12. 구조체와 포인트 관계 (2) | 2018.07.06 |
11. static void 의 쓰임 (0) | 2018.05.25 |
10. __VA_ARGS__ 의 쓰임 (0) | 2018.05.24 |