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

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!geraldo.cc.utexas.edu!slcs.slb.com!PJONES@128.58.42.3
  3. From: pjones@asl.slb.com
  4. Subject: Passing Variable Arguments -twice-
  5. Message-ID: <1992Dec11.185832.20101@slcs.slb.com>
  6. Sender: news@slcs.slb.com (News Administrator)
  7. Nntp-Posting-Host: 129.87.186.2
  8. Reply-To: pjones@asl.slb.com
  9. Organization: Schlumberger/Anadrill Sugar Land, TX
  10. Date: Fri, 11 Dec 92 18:58:32 GMT
  11. Lines: 29
  12.  
  13. I'm trying to pass some arguments to printf() through another routine,
  14. and I can't get it to work.  Here's what I'm doing:
  15.  
  16. void disp_error(char *msg, ...)
  17. {
  18.   /* Screen manipulation stuff */
  19.   .
  20.   .
  21.   .
  22.  
  23.   /* Print the error message */
  24.   cprintf(msg, ...);    <== I want to pass the arguments that disp_error()
  25.                             received directly to the printf() routine without
  26.                             manipulating them.  This compiles but does not
  27.                             work.
  28. }
  29.  
  30. void main(void)
  31. {
  32.   disp_error("This is the letter 'C': %c", 'C');
  33. }
  34.  
  35. Now I know I could use sprintf() in main() and pass the formatted string
  36. to disp_error(),  but this routine is going to be called from a lot of places
  37. and I am trying to avoid that trouble.  I'm sure this is possible to do,  I
  38. just need someone to tell me how.  Thanks in advance.
  39.  
  40. Phil Jones
  41. pjones@asl.sinet.slb.com
  42.