Namespace
Varianti

va_start

Da cppreference.com.
< cpp‎ | utility‎ | variadic

 
 
Utilità libreria
Tipo di supporto (basic types, RTTI, type traits)
Gestione della memoria dinamica
La gestione degli errori
Programma di utilità
Funzioni variadic
Data e ora
Funzione oggetti
initializer_list(C++11)
bitset
hash(C++11)
Gli operatori relazionali
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Coppie e tuple
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
Swap, in avanti e spostare
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
 
Defined in header <cstdarg>
void va_start(va_list ap, parm_n);
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.
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.

Indice

[modifica] 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.

[modifica] 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.

[modifica] 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

[modifica] 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) [edit]
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) [edit]