Functions within structures

Doug Gwyn gwyn at smoke.brl.mil
Fri Nov 9 18:16:36 AEST 1990


In article <2203 at abcom.ATT.COM> mdb at abcom.ATT.COM (5013 ) writes:
-> int   add_rec();
-> int   find_rec();
-> int   quit();
-> unsigned	int	records=0;
-> typedef struct {
->    char    key;
->    int     x_row;
->    int     y_row;
->    char    msg[20];
	int	(*foo)();	/* ADD THIS MEMBER */
-> } MENU;
-> MENU menu[MENU_ITEM+1] = {
->     { '1',7,25,"Add Phone Number",add_rec() },
	/* CHANGE THE ABOVE TO: */
	{ '1', 7, 25, "Add phone number", add_rec },
[...]
->     } ;
[...]
-> menu_opt = select();
-> (*(menu[menu_opt].foo))();
/* That's okay although excessively parenthesized. */



More information about the Comp.lang.c mailing list