Hello, I am currently teaching myself C, and am at a point where I am learning about enumeration. Id really like some help understanding its capabilities. Here in this example I was given.
Is it possible to re work this code such that, the user could be prompted to select a number (corresponding to the colours in the enumeration), so that the output is the colour instead of the coefficient it relates to.Code:#include <stdio.h> enum colours {RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET, NUMBER_OF_COLOURS}; typedef enum colours colour_t; int main(void) { colour_t sky, forest; printf("There are %d colours in the enum\n", NUMBER_OF_COLOURS); sky = BLUE; forest = GREEN; printf("sky = %d\n", (int)sky); printf("forest = %d\n", (int)forest); return 0; }
Is this even possible with enumeration or are these lists just place holders for the value pertaining to it?



).
