00001 #include <stdarg.h>
00002 #include <stdio.h>
00003
00004 #define INTARG 1
00005 #define DBLARG 2
00006
00007 void
00008 printargs(int *arg_type_p, ...)
00009 {
00010 va_list ap;
00011 int arg_type;
00012
00013
00014 while ((arg_type = *arg_type_p++) != 0) {
00015 switch (arg_type) {
00016 case INTARG:
00017 printf("int: %d\n", va_arg(ap, int));
00018 break;
00019 case DBLARG:
00020 printf("double: %f\n", va_arg(ap, double));
00021 break;
00022 }
00023 }
00024
00025 }
00026
00027
00028 int arg_types[] = { INTARG, DBLARG, INTARG, DBLARG, 0 };
00029
00030 int
00031 main()
00032 {
00033 printargs(&arg_types[0], 1, 2.0, 3, 4.0);
00034 return 0;
00035 }