Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ncar!noao!arizona!dwebster From: dwebster@cs.arizona.edu (Dave E. Webster) Newsgroups: comp.lang.c Subject: Re: A question on Function declaration Keywords: pointer function integer Message-ID: <851@caslon.cs.arizona.edu> Date: 13 Feb 91 05:11:13 GMT References: <5806@agate.UUCP> Organization: U of Arizona CS Dept, Tucson Lines: 40 In article <5806@agate.UUCP> joshi@motcid.UUCP (Abhay B. Joshi) writes: >I would like to declare a function which returns a pointer to a function >(that returns an integer). I have been unable to strike at the correct >syntax of such a declaration. > >I tried the following (among others): > ((int *)()) func() ; > >Doesn't work. Abhay: You might try the following: int (*func(int,int)) (float) /* This assumes ANSI C prototypes */ { ... } This defines "func" as a "function with two integer parameters which returns a pointer to a function with a single float parameter which returns an integer." You will need to modify the parameters to suit your particular needs, of course. Note that the parenthesis around the main function prototype are not optional since the `()' have a higher binding precedence than the `*'. This is where c becomes extremely powerful (read EXTREMELY DANGEROUS). Dave 8-}. Newsgroups: comp.lang.c Subject: Re: A question on Function declaration Summary: Expires: References: <5806@agate.UUCP> Sender: Followup-To: Distribution: Organization: U of Arizona CS Dept, Tucson Keywords: pointer function integer