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

void fun (int k, ...) {
    int i, ii, vacount;
    va_list ap;
    char *c;
    int *a;
    double (*b)[6];

    va_start(ap, k);
    vacount = va_count(ap);
    for(i = 0; i<vacount; i++) {
      if(va_isarray(ap)==1) {
         if(va_elementtype(ap) == elementtype(char)) {
           c = va_arg(ap, char *);
           printf("c = %s\n", c);
         }
         else if(va_elementtype(ap) == elementtype(int)) {
           a = va_arg(ap, int *);
           printf("a[0] = %d\n", a[0]);
         }
      }
      else if(va_isarray(ap)==2) {
         b = (double (*)[6])va_arg(ap, double *);
         printf("b[0][0] = %f\n", b[0][0]);
      }
      else 
         ii = va_arg(ap, int);
    }
    va_end(ap);
}

int main() {
   int i;
   char c[10] = "hello"; 
   int a[4] = {8, 2, 3, 4}; 
   array double b[5][6] = { 10, 2};

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