名前空間
変種
操作

va_start

提供: cppreference.com
< cpp‎ | utility‎ | variadic

 
 
ユーティリティライブラリ
支援を入力します (basic types, RTTI, type traits)
動的なメモリ管理
エラー処理
プログラムユーティリティ
可変個引数関数
日付と時刻
関数オブジェクト
initializer_list(C++11)
bitset
hash(C++11)
関係演算子
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>=
ペアとタプル
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)
フォワード、スワップ、および移動
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);
va_startマクロは、名前付き引数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が有効va_listオブジェクトをインスタンスにして呼び出す必要がありますapへの呼び出しの前に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.

目次

[編集] パラメータ

ap -
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 -
最初の変数パラメータを前に付けた名前のパラメータ
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.

[編集] 値を拡大しました

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

[編集]

#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

[編集] も参照してください

次の可変個引数の関数の引数にアクセスします
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.

(関数マクロ) [edit]
可変個引数の関数の引数のトラバーサルは終了します
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.

(関数マクロ) [edit]