I am a bit confused by what for and where enum is good? What are the benefits of using enum against defining global variables (constants) or macros? For instance in this code:
#include<stdio.h>
enum bool {false, true};
int main()
{
enum bool b = 100;
printf("%d", b);
return 0;
}
I can assign even any integer value to b
and every thing works fine, so why not doing
int false = 0, true = 1;
or
#define false 0
#define true 1
in the global scope? Can some one explain where and why are enums useful and should be preferred to use?