arrays of pointers to functions

Jan Christiaan van Winkel jc at atcmp.nl
Sat May 5 05:04:20 AEST 1990


>From article <3032 at ultb.isc.rit.edu>, by waw5805 at ultb.isc.rit.edu (W.A. Willis):
> I have the following declared:
> 
> 		int (*func[])();
> 
> How do I go about initializing func so that it contains pointers to
func0(), func1(), func2(), func3();
extern int func4();
func[1]=func1; func[2]=func2; func[3]=func3; func[4]=func4;
and so on...

This works, because the name of the function alone, without the function
call operator () returns the address of the function.

To call a function,
retcal=(*func[0])();

JC.
-- 
Jan Christiaan van Winkel              Tel: +31 80 566880     jc at atcmp.nl
AT Computing       P.O. Box 1428       6501 BK Nijmegen       The Netherlands



More information about the Comp.lang.c mailing list