Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!crdgw1!sungod!davidsen From: davidsen@sungod.crd.ge.com (William Davidsen) Newsgroups: comp.lang.c Subject: address of function Summary: Several articles answered Keywords: function pointers Message-ID: <757@crdgw1.crd.ge.com> Date: 13 Jun 89 14:44:14 GMT References: <2700@solo8.cs.vu.nl> Sender: news@crdgw1.crd.ge.com Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric Corp. R&D, Schenectady, NY Lines: 51 |From: dooley@helios.toronto.edu (Kevin Dooley) |Subject: array of pointers to functions |Message-ID: <822@helios.toronto.edu> |Date: 12 Jun 89 16:40:18 GMT |Organization: University of Toronto Physics/Astronomy/CITA Computing Consortium |I had a clever idea last night for a completely general routine to |numerically solve a system of N coupled first order differential |equations simultaneously using a Runge-Kutta algorithm. The only |way I can think of to conveniently pass an unspecified number of |pointers to functions is to construct an array of pointers to the |individual functions. Imagine my alarm at discovering that this |is not legal. Why not? Can anybody help me out with this little |puzzle? |From: maart@cs.vu.nl (Maarten Litmaath) |Subject: address of function |Message-ID: <2700@solo8.cs.vu.nl> |Date: 6 Jun 89 17:37:09 GMT |Organization: V.U. Informatica, Amsterdam, the Netherlands | |Why weren't function pointers handled the way below? | | int foo(), (*bar)() = &foo; The following seem to work portably, and would satisfy the two questions aboue. /* function and pointer to it */ int foo(), (*bar)() = foo; /* bar is pointer to foo */ /* vector of pointers to proc */ int curley(), larry(), moe(); int (*procvect[])() = { curley, larry, moe }; demo() { int k; for (k=0; k < 3; ++k) (*procvect[k])(k); } Sure hope this helps you guys. I may have misunderstood the questions, of course. bill davidsen (davidsen@crdos1.crd.GE.COM) {uunet | philabs}!crdgw1!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me