#include <stdio.h>
#include <stdarg.h>
void
f (int w,...)
{
long double x; // Dichiara le variabili che servono
long long int y; // a contenere gli argomenti per i
int z; // quali mancano i parametri formali.
va_list ap; // Dichiara il puntatore agli
// argomenti.
va_start (ap
, w
); // Posiziona il puntatore dopo la // fine di «w».
x
= va_arg (ap
, long double); // Estrae l'argomento // successivo portando
// avanti il puntatore
// di conseguenza.
printf ("w = %i; ", w
); // Mostra il valore del // primo parametro.
printf ("x = %Lf; ", x
); // Mostra il valore // dell'argomento successivo.
y
= va_arg (ap
, long long int); // Estrapola e mostra printf ("y = %lli; ", y
); // il terzo argomento.
z
= va_arg (ap
, int); // Estrapola e mostra printf ("z = %i\n", z
); // il quarto argomento.
va_end (ap
); // Conclude la scansione.
return;
}
int main (int argc, char *argv[])
{
f (10, (long double)12.34, (long long int)13, 14);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRhcmcuaD4KCnZvaWQKZiAoaW50IHcsLi4uKQp7CiAgICBsb25nIGRvdWJsZSB4OyAgICAgLy8gRGljaGlhcmEgbGUgdmFyaWFiaWxpIGNoZSBzZXJ2b25vCiAgICBsb25nIGxvbmcgaW50IHk7ICAgLy8gYSBjb250ZW5lcmUgZ2xpIGFyZ29tZW50aSBwZXIgaQogICAgaW50IHo7ICAgICAgICAgICAgIC8vIHF1YWxpIG1hbmNhbm8gaSBwYXJhbWV0cmkgZm9ybWFsaS4KCiAgICB2YV9saXN0IGFwOyAgICAgICAgLy8gRGljaGlhcmEgaWwgcHVudGF0b3JlIGFnbGkKICAgICAgICAgICAgICAgICAgICAgICAvLyBhcmdvbWVudGkuCgogICAgdmFfc3RhcnQgKGFwLCB3KTsgIC8vIFBvc2l6aW9uYSBpbCBwdW50YXRvcmUgZG9wbyBsYQogICAgICAgICAgICAgICAgICAgICAgIC8vIGZpbmUgZGkgwqt3wrsuCgogICAgeCA9IHZhX2FyZyAoYXAsIGxvbmcgZG91YmxlKTsgLy8gRXN0cmFlIGwnYXJnb21lbnRvCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBzdWNjZXNzaXZvIHBvcnRhbmRvCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhdmFudGkgaWwgcHVudGF0b3JlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBkaSBjb25zZWd1ZW56YS4KCiAgICBwcmludGYgKCJ3ID0gJWk7ICIsIHcpOyAgICAgLy8gTW9zdHJhIGlsIHZhbG9yZSBkZWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBwcmltbyBwYXJhbWV0cm8uCiAgICBwcmludGYgKCJ4ID0gJUxmOyAiLCB4KTsgICAgLy8gTW9zdHJhIGlsIHZhbG9yZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGRlbGwnYXJnb21lbnRvIHN1Y2Nlc3Npdm8uCgogICAgeSA9IHZhX2FyZyAoYXAsIGxvbmcgbG9uZyBpbnQpOyAgLy8gRXN0cmFwb2xhIGUgbW9zdHJhCiAgICBwcmludGYgKCJ5ID0gJWxsaTsgIiwgeSk7ICAgICAgICAvLyBpbCB0ZXJ6byBhcmdvbWVudG8uCgogICAgeiA9IHZhX2FyZyAoYXAsIGludCk7ICAgICAgICAgICAgLy8gRXN0cmFwb2xhIGUgbW9zdHJhCiAgICBwcmludGYgKCJ6ID0gJWlcbiIsIHopOyAgICAgICAgICAvLyBpbCBxdWFydG8gYXJnb21lbnRvLgoKICAgIHZhX2VuZCAoYXApOyAgICAgICAgICAgICAgICAvLyBDb25jbHVkZSBsYSBzY2Fuc2lvbmUuCgogICAgcmV0dXJuOwp9CgppbnQgbWFpbiAoaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkKewogICAgZiAoMTAsIChsb25nIGRvdWJsZSkxMi4zNCwgKGxvbmcgbG9uZyBpbnQpMTMsIDE0KTsKICAgIHJldHVybiAwOwp9