Path: chuka.playstation.co.uk!news From: Craig Graham Newsgroups: scee.yaroze.freetalk.english Subject: Re: Question for the C experts Date: Thu, 03 Sep 1998 23:26:14 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 37 Message-ID: <35EF1786.52A90D88@hinge.mistral.co.uk> References: <35EEB905.940C6E98@ndirect.co.uk> <35EECDB7.334B8EB5@scee.sony.co.uk> <6smqal$l6j17@chuka.playstation.co.uk> NNTP-Posting-Host: 195.184.228.42 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.05 [en] (Win95; I) Nick Slaven wrote: > James Russell wrote in message <35EECDB7.334B8EB5@scee.sony.co.uk>... > >Always a tricky one. Assuming your functions are all "void > functionName(void)" then: > > > >void (*funcIndex[])(void) = { function0, function1, function2 }; > > > >void (*func)(void); > >func = funcIndex[myIndex]; > >func(); > > or alternatively > > I alway's like to define explicit function pointer types to make things a bit more readable: typedef void (*FUNCTION_POINTER_V_V)(void); FUNCTION_POINTER_V_V my_function_array[]={fn0,fn1,fn2}; main() { (my_function_array[n])(); } > Nick S Craig.