home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / c / 3217 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.3 KB  |  42 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!yale!gumby!destroyer!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!chsun!bernina!hoesel
  3. From: hoesel@igc.ethz.ch (Frans van Hoesel)
  4. Subject: typedef void (*generic)()
  5. Message-ID: <1992Dec16.172748.24120@bernina.ethz.ch>
  6. Sender: news@bernina.ethz.ch (USENET News System)
  7. Organization: University of Groningen, the Netherlands
  8. Date: Wed, 16 Dec 1992 17:27:48 GMT
  9. Lines: 31
  10.  
  11. Hi,  
  12.  
  13. I have a problem in doing what I want to do in c.
  14.  
  15. a smaal exaplme
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18.  
  19. typedef void (*generic)();
  20.  
  21. main() {
  22.         generic f,g;
  23.         int     i;
  24.         f = (generic) printf;
  25.         g = (generic) abs;
  26.  
  27.     i=-4;
  28.  
  29.     /* and now do something like :printf("some text %d\n",abs(i)
  30.       ), but using f and g instead !*/
  31. }
  32. This isn't the right group to ask (I know), but propably the best
  33. There is also a remark from my compiler on some constructs stating that void pointer cannot be cast to function pointers. Is this allowed?
  34.  
  35. -- frans
  36.  
  37.  
  38. -- 
  39.       ================================================================
  40.       ===  frans van hoesel               hoesel@igc.ethz.ch       ===
  41.       ================================================================
  42.