Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!abvax!iccgcc!browns From: browns@iccgcc.decnet.ab.com (Stan Brown) Newsgroups: comp.lang.c Subject: Re: A question on Function declaration Message-ID: <3256.27b95578@iccgcc.decnet.ab.com> Date: 13 Feb 91 20:04:24 GMT References: <5806@agate.UUCP> <5807@marble.UUCP> Lines: 30 In article <5807@marble.UUCP>, sland@motcid.UUCP (Stephen Shortland) writes: > 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. I'm just a wussy little fraidy-cat (TM), so I do it in stages. You don't say what arguments either of the functions takes, so I'll assume one takes a char * and the other takes a double. A function that takes a char * and returns an int is 'int func(char *);'. Its type might be called 'FC_I': typedef int FC_I(char *); A pointer to such a function would be a 'FC_I *'. So a function that takes a double and returns such a pointer would be FC_I *desired_func(double); This goes in two steps, unlike the other solutions I've seen. But it's imposible to get the parentheses wrong with this method. Comments from anyone? Disadvantages I've missed? Hey--this is all my opinion, nobody else's. Rely on it at your peril. email: browns@iccgcc.decnet.ab.com Stan Brown, Oak Road Systems, Cleveland, Ohio, USA +1 216 371 0043