sample1a.c

00001 /*
00002  * sample1a.c
00003  */
00004 
00005 #include <stdio.h>
00006 
00007 /* What I find my data with... */
00008 enum MyEnum
00009 {
00010     theFirst,
00011     theSecond,
00012     theThird,
00013     theFourth,
00014 };
00015 #define MyEnumCount = 4;
00016 
00017 /* What I store my data as... */
00018 struct MyData
00019 {
00020     int value;
00021     const char* myStr;
00022 };
00023 
00024 /* What I put my data in... */
00025 const struct MyData myDataList[] = 
00026 {
00027     { 35, "Buggrit" },
00028     { 42, "Millennium" },
00029     { 11, "Hand" },
00030     { 1, "Shrimp" },
00031 };
00032 
00033 /* Do something arbitrary with my data */
00034 void MyDataPrint( enum MyEnum e )
00035 {
00036     const struct MyData* found = myDataList + e;
00037     printf( "%d - %s\n", found->value, found->myStr );
00038 }
00039 
00040 int main( void )
00041 {
00042     MyDataPrint( theFirst );
00043     MyDataPrint( theSecond );
00044     MyDataPrint( theThird );
00045     MyDataPrint( theFourth );
00046     return 0;
00047 }

Generated on Fri Jan 2 15:28:34 2009 for Squat by  doxygen 1.5.6