continue
statement
| General topics | ||||||||||||||||
| Flow control | ||||||||||||||||
| Conditional execution statements | ||||||||||||||||
| Iteration statements (loops) | ||||||||||||||||
|
||||||||||||||||
| Jump statements | ||||||||||||||||
|
||||||||||||||||
| Functions | ||||||||||||||||
| Function declaration | ||||||||||||||||
| Lambda function expression | ||||||||||||||||
inline
specifier
|
||||||||||||||||
| Dynamic exception specifications ( until C++17* ) | ||||||||||||||||
noexcept
specifier
(C++11)
|
||||||||||||||||
| Exceptions | ||||||||||||||||
| Namespaces | ||||||||||||||||
| Types | ||||||||||||||||
| Specifiers | ||||||||||||||||
|
||||||||||||||||
| Storage duration specifiers | ||||||||||||||||
| Initialization | ||||||||||||||||
| Expressions | ||||||||||||||||
| Alternative representations | ||||||||||||||||
| Literals | ||||||||||||||||
| Boolean - Integer - Floating-point | ||||||||||||||||
| Character - String - nullptr (C++11) | ||||||||||||||||
| User-defined (C++11) | ||||||||||||||||
| Utilities | ||||||||||||||||
| Attributes (C++11) | ||||||||||||||||
| Types | ||||||||||||||||
typedef
declaration
|
||||||||||||||||
| Type alias declaration (C++11) | ||||||||||||||||
| Casts | ||||||||||||||||
| Memory allocation | ||||||||||||||||
| Classes | ||||||||||||||||
| Class-specific function properties | ||||||||||||||||
|
||||||||||||||||
| Special member functions | ||||||||||||||||
|
||||||||||||||||
| Templates | ||||||||||||||||
| Miscellaneous | ||||||||||||||||
囲んでいる for 、 range-for 、 while または do-while ループ本体の残りの部分をスキップさせます。
条件文を使用してループの残りの部分を無視することが不適切な場合に使用されます。
目次 |
構文
attr
(オプション)
continue
;
|
|||||||||
説明
continue
文は、
goto
によってループ本体の終端へジャンプするかのように動作します(これは
for
ループ、
range-for
ループ、
while
ループ、および
do-while
ループの本体内部でのみ使用できます)。
より正確には、
while ループの場合、以下のように動作します
while (/* ... */) { // ... continue; // goto continとして動作 // ... contin:; }
do-while ループの場合、以下のように動作します:
do { // ... continue; // goto continとして機能する // ... contin:; } while (/* ... */);
for ループおよび range-for ループでは、以下のように動作します:
for (/* ... */) { // ... continue; // goto continとして動作 // ... contin:; }
キーワード
例
#include <iostream> int main() { for (int i = 0; i < 10; ++i) { if (i != 5) continue; std::cout << i << ' '; // this statement is skipped each time i != 5 } std::cout << '\n'; for (int j = 0; 2 != j; ++j) for (int k = 0; k < 5; ++k) // only this loop is affected by continue { if (k == 3) continue; // this statement is skipped each time k == 3: std::cout << '(' << j << ',' << k << ") "; } std::cout << '\n'; }
出力:
5 (0,0) (0,1) (0,2) (0,4) (1,0) (1,1) (1,2) (1,4)
関連項目
|
C documentation
for
continue
|
|
Cドキュメント
の
continue
|