CompuServe Messages

#Strings in C

    23-Nov-94 16:49:24
Sb: #44205-#Strings in C
Fm: Peter Wade 100265,2740
To: Shraddhan 70374,754
If your function returns a void and takes no parameters, you could use : struct function_entry { char *keyword ; /* keyword is a pointer to a string */ void ( *action ) ( void ) ; /* action is a pointer to a function */ } ; struct function_entry lookup_table [100] ; /* Table of 100 entries */ Change the void at the front if your funtion returns something, change the void in the brackets if it needs parameters. You can fill in the function entries by assigning to the name of a function without the brackets, e.g. : void process_start ( void ) ; /* Defined somewhere in the program */ lookup_table[0].action = process_start ; Then you can execute the function by putting the brackets after it, e.g.: lookup_table[0].action () ; /* Executes funtion through pointer */ I hope this is of help. Peter Wade Autopiloting from London, England