Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!mordor!lll-tis!ptsfa!ihnp4!homxb!houxm!hropus!ka From: ka@hropus.UUCP (Kenneth Almquist) Newsgroups: comp.lang.c Subject: Re: help with declaration Message-ID: <1111@hropus.UUCP> Date: Thu, 18-Jun-87 13:10:45 EDT Article-I.D.: hropus.1111 Posted: Thu Jun 18 13:10:45 1987 Date-Received: Mon, 22-Jun-87 00:50:28 EDT References: <8286@ut-sally.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 24 Keywords: function pointer Given the code: int (*func)(); func = getmenu(); (*func)(); Campbell wants to know how to declare getmenu. Since we want getmenu to return an object of the same type as func, we can simply take the the declaration of func and replace "func" with what looks like a call to getmenu. This gives us: int (*getmenu())(); To define getmenu, say: int (*getmenu())() { ... } Reading the declaration from "inside out", we see that getmenu is a function returning a pointer to a function returning int. Another way to look at it is that (*getmenu())() is a C expression that produces a result of type int. Kenneth Almquist