Pointers to functions on Xenix
Rick Schaut
schaut at madnix.UUCP
Sun Sep 10 11:26:49 AEST 1989
In article <1989Sep8.021802.29203 at Octopus.COM> stever at octopus.UUCP (Steve Resnick ) writes:
[Defines an array of structures where one element of the structure is
a pointer to a function returning an int.]
| /* When I get to the point where I execute an internal function, I call the
| routine here..
| */
| (Cmds[idx].fptr)(c,v); /* Here is where I call the function */
|
| This is what the compiler doesn't like. The error message is something like
|
| Term does not evaluate to a function.
Exactly, the term evaluates to a pointer. You need to go through a level
of indirection to get to the function that the pointer points to. The
correct expression is:
(*Cmds[idx].fptr)(c,v);
See K&R 5.11 (p. 118, 2nd Ed.). See, also, operator precedence on p. 52.
--
Richard Schaut
ArpaNet: madnix!schaut at cs.wisc.edu
UseNet: ...uwvax!astroatc!nicmad!madnix!schaut
{decvax!att}!
More information about the Comp.lang.c
mailing list