Invoking pointers to functions (C sytle)

Christopher R Volpe volpe at camelback.crd.ge.com
Sat Dec 1 10:58:38 AEST 1990


In article <6379 at harrier.ukc.ac.uk>, dac at ukc.ac.uk (David Clear) writes:
|>main()
|>{
|>	int fred(), (*p)();
|>
|>	p = fred;
|>
|>	(*p)(10);		/* The right way */
|>	p(10);			/* This works too */
|>}
|>Q: Is p(args) legal, portable C?

Yes

|>Q: Is p(args) preferential to (*p)(args) as it looks neater, compare:
|>	s->p(args)	(*s->p)(args)

I prefer (*p)(args) because the use matches the declaration and doesn't
cause me to go running around looking for the prototype declaration of
"function p". BTW, (*fred)() is just as legal as fred(). 
                          
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com



More information about the Comp.lang.c mailing list