home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / xv221src / unsupt / vargs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-28  |  882 b   |  39 lines

  1. /*
  2.  * vargs.c   -  a simple program that tests the 'varargs' handling on your
  3.  *              compiler.  Many folks probably have a 'gcc' that has improperly
  4.  *              installed include files.  On such systems, this program will
  5.  *              not work (nor will *any* 'varargs' using program compiled with
  6.  *              gcc, most notably XV).  If such is the case, get your sysadmin
  7.  *              to fix the gcc installation on your machine.  Or use cc.
  8.  */
  9.  
  10.  
  11. #include <stdio.h>
  12. #include <varargs.h>
  13.  
  14. void test();
  15.  
  16. main()
  17. {
  18.   test(1, "foobie", 0);
  19. }
  20.  
  21. void test(va_alist)
  22. va_dcl
  23. {
  24.   va_list args;
  25.   int i;
  26.   char *foo;
  27.  
  28.   va_start(args);
  29.   i = va_arg(args, int);
  30.   fprintf(stderr,"i = %d\n", i);
  31.  
  32.   foo = va_arg(args, char *);
  33.   if (!foo) fprintf(stderr,"foo = nil\n");
  34.   else fprintf(stderr,"foo = '%s'\n",foo);
  35.  
  36.   va_end(args);
  37. }
  38.  
  39.