Is there a one-liner that lets me output the current value of an enum?
I had the same problem.
I had to print the color of the nodes where the color was: enum col { WHITE, GRAY, BLACK }; and the node: typedef struct Node { col color; };
I tried to print node->color with printf("%s\n", node->color); but all I got on the screen was (null)\n.
The answer bmargulies gave almost solved the problem.
So my final solution is:
static char *enumStrings[] = {"WHITE", "GRAY", "BLACK"};
printf("%s\n", enumStrings[node->color]);