#include <stdargh>
#include <stdio.h>
double mini(double first, ...) {
va_list pointeur; /* Initialement non affecté */
double m=first, next=first);
/* On capture la valeur &first */
va_start(pointeur,first);
/* On traite chaque paramètre */
while(next>=0) {
if (next<m) m=next;
next = (double)va_arg(pointeur, double);
}
va_end(pointeur);
return m;
}
int main(void) {
int m1 = mini(3.2,5,8.6,12.9,6,2.1, -1) ;
int m2 = mini(4.3,6.1, -1) ;
printf("m1 = %lf\n", m1); /* 2.1 */
printf("m2 = %lf\n", m2); /* 4.3 */
return 0;
}