1. 程式人生 > >每日程式設計訓練20150909:typedef void (* unitest_func_t) (void);

每日程式設計訓練20150909:typedef void (* unitest_func_t) (void);

#include <stdio.h>
#include <string.h>

typedef void (* unitest_func_t) (void);

typedef struct
{
        int id;
        unitest_func_t func;
}unitest_t;

void unitest_hello(void)
{
        printf("hello unitest!\r\n");
}

const unitest_t unitest_table[] = {

        {0,     (void*)0         },
        {1,     unitest_hello    },
        {0,     (void*)0         },
};

int main(int argc, char* argv[])
{
        int i;

        printf("hello world!\r\n");

        for (i = 0; i < sizeof(unitest_table)/sizeof(unitest_table[0]); i++) {
                if (0 != unitest_table[i].id) {
                        unitest_table[i].func();
                }
	}
}