Unnamed Enumeration Types - C Data Type

C examples for Data Type:enum

Introduction

You can create variables of an enumeration type without specifying a tag, so there's no enumeration type name.

Because there is no type name, there's no way to define additional variables of this type later in the code.

Demo Code


#include <stdio.h> 
int main(void) { 
  enum {red, orange, yellow, green, blue, indigo, violet} shirt_color;
  
  shirt_color = red;//from w w w  . ja va  2s  . c  om

  printf("%d\n",shirt_color);  
  return 0; 
}

Result


Related Tutorials