From: "John M. Aldrich" Newsgroups: comp.lang.c,comp.os.msdos.djgpp Subject: Re: Casting void pointers Date: Sun, 21 Jun 1998 22:31:22 -0400 Organization: Two pounds of chaos and a pinch of salt. Lines: 33 Message-ID: <358DC1FA.443E297D@cs.com> References: <6mkaos$k7o AT dfw-ixnews6 DOT ix DOT netcom DOT com> NNTP-Posting-Host: ppp146.cs.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Todd Rowan wrote: > > How do you explicity cast a void pointer to a function pointer? Or do you > even need to cast void pointers manually? If you want to be able to access the data pointed to by a void pointer, then you must typecast it to something. I'm not entirely sure why you'd want to store a function pointer in a void pointer, but you'd cast it in the same way that you would declare a function pointer: #include int foo( int x ) { return x + 10; } int main( void ) { void *vp = foo; int x = ((int (*)(int)) vp)( 10 ); printf( "%d\n", x ); return 0; } hth! -- --------------------------------------------------------------------- | John M. Aldrich | "Sin lies only in hurting other | | aka Fighteer I | people unnecessarily. All other | | mailto:fighteer AT cs DOT com | 'sins' are invented nonsense." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------