/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#include <stdarg.h>

void fun (int k, ...) {
    int i, vacount;
    int a;
    double b;
    va_list ap;

    va_start(ap, k);
    vacount = va_count(ap);
    printf("vacount = %d\n", vacount);
    if(va_datatype(ap) == CH_INTTYPE)  {
      a = va_arg(ap, int);
      printf("data type is int, a = %d\n", a);
    }
    else if(va_datatype(ap) == CH_DOUBLETYPE)  {
      b = va_arg(ap, int);
      printf("data type is double, b = %f\n", b);
    }
    va_end(ap);
}

int main() {
   int i;
   int a=10;
   double b = 20;

   fun(i, a);
   fun(i, b);
}
