#include #ifdef __STDC__ #include #else #include #endif #ifdef __STDC__ void f(int field, ...); #else void f(); #endif void main() { f(1, "string"); f(2, 17, 4); f(3, 8); f(2, 4, 17); f(1, "another string"); } #ifdef __STDC__ void f(int field,...) #else void f (va_alist) va_dcl #endif { va_list ap; #ifndef __STDC__ int field; #endif int int1, int2; char *s; #ifdef __STDC__ va_start (ap, field); #else va_start (ap); field = va_arg(ap, int); #endif switch ( field ) { case 1: s = va_arg (ap, char *); printf ("1 string: %s\n", s); break; case 2: int1 = va_arg (ap, int); int2 = va_arg (ap, int); printf ("2 nubers: %d, %d\n", int1, int2); break; case 3: int1 = va_arg (ap, int); printf ("1 number: %d\n", int1); break; default: printf ("error: %d\n", field); break; } va_end (ap); }