functions returning pionters to functions
stevens at inuxh.UUCP
stevens at inuxh.UUCP
Sat Dec 17 00:47:11 AEST 1983
> The declaration 'int (*ptr)()' defines 'ptr' as a pointer to
> an integer function. What you want to do is replace 'ptr' with
> your function definition of 'getroutine(name, table)', thus
> giving 'int (*(getroutine(name, table)))()' which defines
> getroutine as a function with two arguements which returns a
> pointer to an integer function (or function that returns an
> integer).
>
> Note that 'ptr' was replaced by '(getroutine(name, table))'.
> The enclosing parenthesis are necessary to bind the arguements
> to getroutine before the * (pointer binding) is applied.
No, the parentheses around '(getroutine(name, table))' are not required.
function arguments `()' bind more tightly than pointer dereferencing `*'.
(K & R, p. 49 [the page my K & R falls open to]).
--
Scott Stevens
AT&T Consumer Products Laboratories
Indianapolis, Indiana
UUCP: inuxh!stevens
More information about the Comp.unix
mailing list