A question on Function declaration

Dave E. Webster dwebster at cs.arizona.edu
Wed Feb 13 16:11:13 AEST 1991


In article <5806 at agate.UUCP> joshi at 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 at agate.UUCP>
Sender: 
Followup-To: 
Distribution: 
Organization: U of Arizona CS Dept, Tucson
Keywords: pointer function integer



More information about the Comp.lang.c mailing list