home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!geraldo.cc.utexas.edu!slcs.slb.com!PJONES@128.58.42.3
- From: pjones@asl.slb.com
- Subject: Passing Variable Arguments -twice-
- Message-ID: <1992Dec11.185832.20101@slcs.slb.com>
- Sender: news@slcs.slb.com (News Administrator)
- Nntp-Posting-Host: 129.87.186.2
- Reply-To: pjones@asl.slb.com
- Organization: Schlumberger/Anadrill Sugar Land, TX
- Date: Fri, 11 Dec 92 18:58:32 GMT
- Lines: 29
-
- I'm trying to pass some arguments to printf() through another routine,
- and I can't get it to work. Here's what I'm doing:
-
- void disp_error(char *msg, ...)
- {
- /* Screen manipulation stuff */
- .
- .
- .
-
- /* Print the error message */
- cprintf(msg, ...); <== I want to pass the arguments that disp_error()
- received directly to the printf() routine without
- manipulating them. This compiles but does not
- work.
- }
-
- void main(void)
- {
- disp_error("This is the letter 'C': %c", 'C');
- }
-
- Now I know I could use sprintf() in main() and pass the formatted string
- to disp_error(), but this routine is going to be called from a lot of places
- and I am trying to avoid that trouble. I'm sure this is possible to do, I
- just need someone to tell me how. Thanks in advance.
-
- Phil Jones
- pjones@asl.sinet.slb.com
-