C 언어
enum
SpeeDr00t
2016. 7. 12. 09:57
반응형
enum
1. 문법
enum type_name{ value1, value2,...,valueN };
type 1
// Changing the default value of enum elements enum suit{ club=0; diamonds=10; hearts=20; spades=3; };
type 2
enum boolean{ false; true; }; enum boolean check;
2. 테스트 소스
#include <stdio.h> enum week{ sunday, monday, tuesday, wednesday, thursday, friday, saturday}; int main(){ enum week today; today = wednesday; printf("%d day\n",today+1); return 0; }
3. 결과
hacker@HACKER:~/c$ gcc -o enum1 enum1.c hacker@HACKER:~/c$ ./enum1 4 day
반응형