Espacios de nombres
Variantes
Acciones

va_start

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

 
 
Utilidades de la biblioteca
Escriba apoyo (basic types, RTTI, type traits)
Gestión de memoria dinámica
Gestión de errores
Programa de servicios públicos
Funciones variadic
Fecha y hora
Objetos Function
initializer_list(C++11)
bitset
hash(C++11)
Operadores relacionales
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>=
Pares y tuplas
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)
Cambiar, hacia adelante y mover
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 permite el acceso a los argumentos de variable tras el argumento con nombre 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 es conveniente recurrir a una instancia de un objeto válido va_list ap antes de cualquier llamada a 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.

Contenido

[editar] Parámetros

ap -
una instancia del tipo de 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 -
el parámetro llamado anterior a la primera parámetro variable
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.

[editar] Ampliado valor

(Ninguno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Ejemplo

#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

[editar] Ver también

accede a la función siguiente argumento 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.

(función macro) [edit]
termina recorrido de los argumentos de la función 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.

(función macro) [edit]