Path: utzoo!attcan!uunet!husc6!purdue!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: Casting function ptrs Message-ID: <550@goofy.megatest.UUCP> Date: 19 May 88 22:21:11 GMT References: <281@marob.MASA.COM> Organization: Megatest Corporation, San Jose, Ca Lines: 35 in article <281@marob.MASA.COM>, daveh@marob.MASA.COM (Dave Hammond) says: > > > Given a list of varying typed functions, their names and addresses: > > struct funcs { > char *name; > unsigned (*func)(); > } > char *foo(); > struct funcs f = { "foo", (char *)foo }; ... typedef unsigned (*func_ptr)(); struct funcs { char* name; func_ptr func; } func_table; func_ptr func_lookup() { ... whatever ... } { func_ptr proc; char* func_name = ... whatever ...; unsigned result; if((proc = func_lookup(func_name)) != (func_ptr)0) result = (*proc)(); else fprintf(stderr, "Shucks.\n"); }