home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18965 < prev    next >
Encoding:
Text File  |  1993-01-11  |  1.3 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. From: nikki@trmphrst.demon.co.uk (Nikki Locke)
  3. Path: sparky!uunet!pipex!demon!trmphrst.demon.co.uk!nikki
  4. Subject: Re: varargs
  5. Reply-To: nikki@trmphrst.demon.co.uk
  6. References: <1993Jan10.193617.5871@news.acns.nwu.edu>
  7. Distribution: world
  8. X-Mailer: cppnews $Revision: 1.30 $
  9. Organization: Trumphurst Ltd.
  10. Lines: 29
  11. Date: Mon, 11 Jan 1993 19:52:12 +0000
  12. Message-ID: <726807132snx@trmphrst.demon.co.uk>
  13. Sender: usenet@demon.co.uk
  14.  
  15. In article <1993Jan10.193617.5871@news.acns.nwu.edu> ecm@casbah.acns.nwu.edu (Edward Malthouse) writes:
  16. > I am trying to write a function error which will will be declared as follows:
  17. > error(va_list)
  18. > The usage will be
  19. > error(char *format, arg_list)
  20.  
  21. Do you have some kind of problem with stdarg.h ? This is the standard 
  22. method of doing variable argument lists, not the old varargs stuff.
  23.  
  24. #include <stdarg.h>
  25.  
  26. error(char *format, ...)
  27. {
  28.     va_list args;
  29.  
  30.     va_start(args, format);
  31.     vfprintf(stderr, format, args);
  32.     va_end(args);
  33.     cleanup();
  34.     exit(1);
  35. }
  36.  
  37. I expect that, even with the old varargs stuff, you need to call vfprintf,
  38. not fprintf. I am rather suspicious of your function declaration, also.
  39.  
  40. -- 
  41. Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
  42. trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
  43.