10
Enumerations
- #include <stdio.h>
- main() {
- enum boolean {false, true} yes = true, no = false;
- const int FALSE = 0, TRUE = !FALSE;
- printf("false=%d\n", false);
- printf("true=%d\n", true);
- printf("yes=%d\n", yes);
- printf("no=%d\n", no);
- printf( yes == no ? "What?\n" : "Ok\n" );
- printf("\n");
- printf("FALSE=%d\n", FALSE);
- printf("TRUE=%d\n", TRUE);
- }
$ gcc -o enum enum.c
$ ./enum
false=0
true=1
yes=1
no=0
Ok
FALSE=0
TRUE=1
Comments