summaryrefslogtreecommitdiff
path: root/reference/C/EXAMPLES/enum3.c
blob: 97b79b4a034e8b3a70e85de77dfeca91218ad1a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/****************************************************************************
 *
 *  Enumeration example: This program will fail to compile because
 *  'Alex' is in both enum lists.
 *
 ****************************************************************************/
main()
{

  enum People1 {Alex=0,    Tracy,  Kristian} Girls;
  enum People2 {William=0, Martin, Alex}     Boys;
  /*     A      A
         |      |
         |      |
         |      -------  list of aliases.
         --------------  Enumeration tag.	*/
    

  switch (Boys)
  {
  case William:
    puts("William");
    break;

  case Martin:
    puts("Martin");
    break;

  case Alex:
    puts("Alex");
    break;

  default:
    break;
  }
}