Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 8/28/84; site lll-crg.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!umcp-cs!gymble!lll-crg!brooks From: brooks@lll-crg.ARPA (Eugene D. Brooks III) Newsgroups: net.lang.c Subject: Re: Array of pointers to functions Message-ID: <535@lll-crg.ARPA> Date: Sun, 21-Apr-85 17:45:22 EST Article-I.D.: lll-crg.535 Posted: Sun Apr 21 17:45:22 1985 Date-Received: Tue, 23-Apr-85 01:24:07 EST References: <243@osiris.UUCP> Distribution: net Organization: Lawrence Livermore Labs, CRG group Lines: 26 Declaring arrays of pointers to functions returning pointers to what ever is always a pain to get straight. The slickest solution (other than having godlike mental powers) is documented in "C Notes" by Zahn. You use a set of typedefs to get the job done a step at a time. /* First the type that the function returns. */ typedef int *PI; /* PI is a pointer to an int. */ /* Now the function type. */ typedef PI FPI(); /* FPI is a function returning a pointer to an int. */ /* Now pointer to the above function. */ typedef FPI *PFPI; /* PFPI is a pointer to a function returning a pointer to an int. */ Now an array of these pointers is as for any array. PFPI array[10]; /* An array of function pointers of size 10. */ By building up these rather complicated declarations using typedefs the logic of what you are declaring and how to use it is it bit easier to understand. See "C Notes" by Zahn for a longer explanation of the above and the corrections to any possible errors in the preceeding description.