Here's the complete emit() function:
void emit(const char *fmt,...)
{
va_list ap /*will point to each unnamed argument in turn*/
int num;
double d;
const char *p=fmt;
va_start(ap,fmt); /* point to first element after fmt*/
while(*p)
{
if (*p=='i') /*int*/
{
num=va_arg(ap,int);
printf("%d",num);
}
else if (*p=='d') /*double*/
{
d=va_arg(ap,double);
printf("%f",d);
}
else
{
printf("unsupported format flag");
break;
}
++p;
}/*while*/
va_end(ap) /*cleanup*/
}
int main()
{
double salary=1000.00;
int id=1234;
emit("di",salary, id);
}

















