Function returning pointer to function ?

John Woods john at frog.UUCP
Thu Jul 18 01:57:11 AEST 1985


> 	Is it legal for a function to return a pointer to a function?
> It seems like it should be, but if so, how would one define and
> declare such a function?
> 

typedef int (*pfi)();

int spiffy() {
	return 0x69;
}

pfi foobar() {
	return spiffy;
}

There you have it.  It's simple, and EVEN readable.  Nearly so, anyway.


--
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc at MIT-XX.ARPA

I have a bad habit of thinking of tremendously witty .signatures just before
I fall asleep.  If I kept paper by my bed, you'd probably be laughing
uncontrollably at this very moment.  Sorry.



More information about the Comp.lang.c mailing list