[comp.unix.ultrix] <varargs.h> on the DECstation 3100

pmaresch@hawk.ulowell.edu (Pierre Mareschal) (06/28/90)

Hi, I encountered some problem on the DECstation 3100 with varargs.
The simple program below doesn't work if I change all the occurence
of double by float. Why?

What is the difference between varargs and stdarg?

Thanks for anwering.

Pierre.

----
#include <varargs.h>

void f(va_alist) va_dcl {
		va_list ap;
        char *p, *sval, *fmt;
        int ival;
        double fval;

        va_start(ap);
        fmt = va_arg(ap, char*);
        for(p = fmt; *p; p++) {
            if(*p != '%')
                putchar(*p);
            else
                switch(*++p) {
                case 'f':
                    fval = va_arg(ap, double);
                    printf("%f",fval);
                    break;
                case 'd':
                    ival = va_arg(ap, int);
                    printf("%d",ival);
                    break;
                case 's':
                    sval = va_arg(ap, char*);
                    printf("%s",sval);
                    break;
                }
        }
        va_end();
}

main() {
		double w = 4.7;
        f("%s : %d %d %d %f\n", "test", 3, 2, 1, w);
}
----
:- pmaresch@hawk.ulowell.edu