[1725989] | 1 | #include <stdio.h> |
---|
| 2 | #include <stdlib.h> |
---|
| 3 | //#include <fstream.hfa> |
---|
| 4 | |
---|
| 5 | enum color { red, blue, green }; |
---|
| 6 | //enum color c1 = 0; |
---|
| 7 | //enum color c2 = 1; |
---|
| 8 | enum color c3 = 2; |
---|
| 9 | int c = red; |
---|
| 10 | |
---|
| 11 | static const int one = 0 + 1; |
---|
| 12 | static const void * NIL = NULL; |
---|
| 13 | static const double PI = 3.14159; |
---|
| 14 | static const char Plus = '+'; |
---|
| 15 | static const char * Fred = "Fred"; |
---|
| 16 | static const int Mon = 0, Tue = Mon + 1, Wed = Tue + 1, Thu = Wed + 1, Fri = Thu + 1, |
---|
| 17 | Sat = Fri + 1, Sun = Sat + 1; |
---|
| 18 | |
---|
| 19 | void foo() { |
---|
| 20 | const int r = random() % 100; |
---|
| 21 | int va[r]; |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | struct Person { char * name; int age, height; }; |
---|
| 25 | |
---|
| 26 | //enum E { A, B, C }; |
---|
| 27 | |
---|
| 28 | enum { X = 10, Y = 9, Z = -5 }; |
---|
| 29 | enum { A, B, C = 10, D, E = 10 }; |
---|
| 30 | |
---|
| 31 | enum { Size = 20, Max = 10, MaxPlus10 = Max + 10, Max10PlusOne }; |
---|
| 32 | |
---|
| 33 | //enum( Person ) friends { Liz = { "ELIZABETH", 22, 170 }, Beth = Liz, |
---|
| 34 | // Jon = { "JONATHAN", 35, 190 } }; |
---|
| 35 | |
---|
| 36 | void www( int p ) {} |
---|
| 37 | |
---|
| 38 | int main() { |
---|
| 39 | printf( "%d\n", Size ); |
---|
| 40 | struct /* unnamed */ { int i; } x, y, z; |
---|
| 41 | x.i = 3; |
---|
| 42 | www( x.i ); |
---|
| 43 | |
---|
| 44 | struct S { |
---|
| 45 | union /* unnamed */ { // unscoped fields |
---|
| 46 | int i; double d ; char ch; |
---|
| 47 | }; |
---|
| 48 | }; |
---|
| 49 | |
---|
| 50 | struct S s; |
---|
| 51 | s.i = 3; |
---|
| 52 | s.d = 3.5; |
---|
| 53 | |
---|
| 54 | const int r = random(); |
---|
| 55 | int sa[Sun]; |
---|
| 56 | |
---|
| 57 | enum Week { Mon, Tue, Wed, Thu = 10, Fri, Sat, Sun }; |
---|
| 58 | enum Week week; |
---|
| 59 | switch ( week ) { |
---|
| 60 | case Mon: case Tue: case Wed: case Thu: case Fri: |
---|
| 61 | printf( "weekday\n" ); |
---|
| 62 | case Sat: case Sun: |
---|
| 63 | printf( "weekedn\n" ); |
---|
| 64 | } |
---|
| 65 | for ( enum Week day = Mon; day <= Sun; day = (enum Week)(day + 1) ) { |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | // int jane_pos = posnE( Mon ); |
---|
| 69 | // char * jane_value = valueE( Jane ); |
---|
| 70 | // char * jane_label = labelE( Names.Jane ); |
---|
| 71 | // sout | labelE( Names.Jane ) | valueE( Names.Jane ); |
---|
| 72 | } |
---|