Invoking pointers to functions (C sytle)
David Clear
dac at ukc.ac.uk
Sat Dec 1 04:20:27 AEST 1990
Take a look at this:
main()
{
int fred(), (*p)();
p = fred;
(*p)(10); /* The right way */
p(10); /* This works too */
}
int
fred(x)
...
The (*p)(args) invocation is the K&R standard. p(args) also works on at
least 4 different Unix compilers.
Q: Is p(args) legal, portable C?
Q: Is p(args) preferential to (*p)(args) as it looks neater, compare:
s->p(args) (*s->p)(args)
Any thoughts? I've only ever used (*p)()... I only came across p() recently.
Dave.
More information about the Comp.lang.c
mailing list