home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16685 < prev    next >
Encoding:
Text File  |  1992-11-17  |  1.3 KB  |  45 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!portal!dfuller
  3. From: dfuller@portal.hq.videocart.com (Dave Fuller)
  4. Subject: Re: Multiple Parameter Passing (unspecified number)
  5. Message-ID: <BxvnxL.67v@portal.hq.videocart.com>
  6. Organization: VideOcart Inc.
  7. X-Newsreader: Tin 1.1 PL3
  8. References: <1992Nov17.105837.21867@henson.cc.wwu.edu>
  9. Date: Tue, 17 Nov 1992 20:36:57 GMT
  10. Lines: 33
  11.  
  12. n8743196@henson.cc.wwu.edu (Jeff Wandling) writes:
  13. : System: Sun 3/50, SunOS 4.1.1b
  14. : I'm trying to do a similar thing, except my function doesn't know what type
  15. : to expect.  The next "variable argument" could be any simple type.  How
  16. : do I deal with this?  Is there a way to switch on the type of the next
  17. : argument? When using union's for example---
  18. :   hash_insert(table,name,...) 
  19. :   ....
  20. :   {
  21. :     
  22. :     ....
  23. :     va_list argp;
  24. :     type = va_"type?"(argp,???);
  25. :     
  26. :     ....
  27. :    }
  28.  
  29. Only if used like printf().  Printf knows what to cast the next parm as 
  30. because you tell it what type you are passing it in the display description
  31. string.  i.e. "num %d: name:%s"
  32. printf will cast the first parm to an int, the second to a char*.
  33. If you want pass random types, you have to also give the routine a way
  34. of knowing what the values are supposed to be.
  35.  
  36. Dave Fuller
  37. dfuller@portal.hq.videocart.com
  38.  
  39.