va_start
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody>| Elemento definito nell'header <cstdarg>
|
void va_start(va_list ap, parm_n); |
||
</tbody>
La macro
va_start permette di accedere ai seguenti argomenti variabili l'argomento di nome parm_n. Original:
The
va_start macro enables access to the variable arguments following the named argument parm_n. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
va_start deve essere richiamato con un istanza con un oggetto valido va_list ap prima delle chiamate al va_arg.Original:
va_start should be invoked with an instance to a valid va_list object ap before any calls to va_arg.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parametri
| ap | - | un'istanza del tipo va_list
Original: an instance of the va_list type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| parm_n | - | il parametro denominato precedente il primo parametro variabile
Original: the named parameter preceding the first variable parameter The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Expanded valore
(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Esempio
#include <iostream>
#include <cstdarg>
int add_nums(int count, ...)
{
int result = 0;
va_list args;
va_start(args, count);
for (int i = 0; i < count; ++i) {
result += va_arg(args, int);
}
return result;
}
int main()
{
std::cout << add_nums(4, 25, 25, 50, 50) << '\n';
}
Output:
150
Vedi anche
accede l'argomento successivo funzione variadic Original: accesses the next variadic function argument The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione macro) | |
termina attraversamento degli argomenti della funzione variadic Original: ends traversal of the variadic function arguments The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione macro) | |