Code /* testVar.cpp David G. Klick CIS 250 2006-02-20 Demonstrates use of variable argument list. Do NOT do this in C++ if you can avoid it (and you CAN avoid it). */ #include #include void display(const char* fmt, ...); int main(void) { display("iff", 15, 6.8, 3.2); return 0; } void display(const char* fmt, ...) { va_list varlist; char c; const char *p = fmt; va_start(varlist, fmt); while (c = *p) { switch (c) { case 'i': printf("%d ", va_arg(varlist, int)); break; case 'f': printf("%f ", va_arg(varlist, double)); break; default: printf("%c", c); } p++; } printf("\n"); va_end(varlist); }