A question on Function declaration
Brian Bliss
bliss at sp64.csrd.uiuc.edu
Thu Feb 14 08:37:25 AEST 1991
> I would like to declare a function which returns a pointer to a function
>(that returns an integer).
int (*f( ))();
^arg list goes here
(arg list for returned func goes in trailing parens)
>I tried the following (among others):
> ((int *)()) func() ;
it is never legal to put parenthesis
around a type specifier, except when
performing the cast operation.
just remember that declaration look like
the var's usage, so you have
a function f:
f();
a function returning a pointer:
* f(); or
*(f()); "apply the function, then dereference the ptr"
a function returning a pointer to a function
(*f())(); or
(*(f()))(); "apply the function, deref ptr, apply result"
bb
More information about the Comp.lang.c
mailing list