A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4140/stmt.for below:

[stmt.for]

6.5.3 The for statement [stmt.for] 1

The for statement

for ( for-init-statement conditionopt ; expressionopt ) statement

is equivalent to

{
	for-init-statement
	while ( condition ) {
		statement
		expression ;
	}
}

except that names declared in the for-init-statement are in the same declarative region as those declared in the condition, and except that a continue in statement (not enclosed in another iteration statement) will execute expression before re-evaluating condition. [ Note: Thus the first statement specifies initialization for the loop; the condition ([stmt.select]) specifies a test, made before each iteration, such that the loop is exited when the condition becomes false; the expression often specifies incrementing that is done after each iteration.  — end note ]

2

Either or both of the condition and the expression can be omitted. A missing condition makes the implied while clause equivalent to while(true).

3

If the for-init-statement is a declaration, the scope of the name(s) declared extends to the end of the for statement. [ Example:

int i = 42;
int a[10];

for (int i = 0; i < 10; i++)
  a[i] = i;

int j = i;          // j = 42

 — end example ]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4