Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!caen!uflorida!reef.cis.ufl.edu!pm0 From: pm0@reef.cis.ufl.edu (Patrick Martin) Newsgroups: comp.lang.c Subject: void * = pointer to a function Message-ID: <27385@uflorida.cis.ufl.EDU> Date: 10 Mar 91 09:26:53 GMT Sender: seeger@uflorida.cis.ufl.EDU Distribution: comp.lang.c Organization: UF CIS Dept. Lines: 38 I am trying to get a grip on pointers to functions. Here is the code I am having a problem with (Simplified to the bare essense of the problem) #include int Output_Num(int a) { printf("The Number is: %d",a); } main() { void *Function = (int (*) (int)) Output_Num; (*Function) (5); } I want to declare an object which is actually a pointer to a function so I may call it through the other object instead. I did read K&R's section on pointers to functions but still could not get this code to work. One more question, what would the code look like if the function were: void Hello_World() {printf("Hello world")} main() { void *F = (void (*) (void)) Hello_World; /* can I use () in place of (void)? */ (*F) (); /* or should the call be (*F) (void) */ Thanks, Pat Martin