Define and use enum : Enum « Data Type « C / ANSI-C






Define and use enum


#include <stdio.h>

enum computer {keyboard, CPU, screen, printer, mouse};

int main(void)
{
  enum computer comp;

  comp = CPU;

  printf("%d", comp);

  return 0;
}


           
       








Related examples in the same category

1.Map enum to char and output with for loop
2.Map enum to char array
3.Reference enum value by int
4.Map enum to string array