| ??? 11/16/06 22:44 Read: times |
#128137 - Something like this? Responding to: ???'s previous message |
typedef void (*fp)(void); //function pointer
typedef struct
{
char *command;
fp function;
} command_t;
command_t cmd_array[] =
{
{ "START", STARTExecute },
{ "STOP", STOPExecute },
{ "DUMP", DUMPExecute },
};
i=0;
while (i < sizeof(cmd_array) / sizeof(command_t))
{
if (strcmp (cmd_array[i].command, rx_buf) == 0)
{// if the command is found, call the function
cmd_array[i].function();
}
} |
| Topic | Author | Date |
| (SDC)C how to 2 | 01/01/70 00:00 | |
| Something like this? | 01/01/70 00:00 | |
| maybe this is it... | 01/01/70 00:00 | |
| I would use switch | 01/01/70 00:00 | |
| One advantage | 01/01/70 00:00 | |
Yeah you are right its not that bizzare | 01/01/70 00:00 |



