A question on Function declaration

Bob Martin rmartin at clear.com
Fri Feb 15 05:20:09 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.
>
>Thanks for any hints/answers.
>
>-- Abhay --

Try this one.  Net people please check!!!

		int (*p)()		p is a pointer to a function returning int.

		(int (*)()) f() f is a func returning a pointer to a func 
						returning int.


You are much better off building your type via typedefs!!

typedef int (*pfint)();	/* ptr to function returning int */

pfint f();	/* declares f as func returning ptr to func returning int */



-- 
+-Robert C. Martin-----+:RRR:::CCC:M:::::M:| Nobody is responsible for |
| rmartin at clear.com    |:R::R:C::::M:M:M:M:| my words but me.  I want  |
| uunet!clrcom!rmartin |:RRR::C::::M::M::M:| all the credit, and all   |
+----------------------+:R::R::CCC:M:::::M:| the blame.  So there.     |



More information about the Comp.lang.c mailing list