Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!pt!ius2.cs.cmu.edu!edw From: edw@ius2.cs.cmu.edu (Eddie Wyatt) Newsgroups: comp.lang.c Subject: Re: help with declaration Message-ID: <1206@ius2.cs.cmu.edu> Date: Wed, 17-Jun-87 19:46:15 EDT Article-I.D.: ius2.1206 Posted: Wed Jun 17 19:46:15 1987 Date-Received: Tue, 23-Jun-87 01:02:55 EDT References: <8286@ut-sally.UUCP> Organization: Carnegie-Mellon University, CS/RI Lines: 40 Keywords: function pointer In article <8286@ut-sally.UUCP>, atc@ut-sally.UUCP (Alvin T. Campbell III) writes: > > I have a question for all you C wizards out there. I want to write > a function which returns a pointer to another function. I checked Kernighan > & Ritchie and Harbison & Steele, but found no solution. > > A. T. Campbell > University of Texas at Austin > Computer Graphics Lab > atc@sally.CS.UTEXAS.EDU Syntax is : ( * ( ) ) ( ) Example definition for a function that returns a pointer to a function that returns an int : int tt(); int (*foobar(x))() int x; { printf("x = %d\n",x); return(tt); } int tt() { printf("Hello world\n"); return(1); } main() { int (*func)(); func = foobar(3); printf("func returns %d\n",func()); } -- Eddie Wyatt e-mail: edw@ius2.cs.cmu.edu