Skip to content

Commit b125d48

Browse files
authored
Merge pull request #2815 from corob-msft/cr-dd1052043
Fix for DD105243 missing F1 keyword for "for"
2 parents 43a4d53 + 3686947 commit b125d48

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/cpp/for-statement-cpp.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: "for Statement (C++)"
3-
ms.date: "11/04/2016"
3+
description: "Reference to the Standard C++ for statement in Microsoft Visual Studio C++."
4+
f1_keywords: ["for_cpp"]
5+
ms.date: "04/14/2020"
46
helpviewer_keywords: ["for keyword [C++]"]
57
ms.assetid: 6c7d01b3-c4c1-4c6a-aa58-e2d198f33d4a
68
---
@@ -10,10 +12,8 @@ Executes a statement repeatedly until the condition becomes false. For informati
1012

1113
## Syntax
1214

13-
```
14-
for ( init-expression ; cond-expression ; loop-expression )
15-
statement;
16-
```
15+
> **`for (`** *init-expression* **`;`** *cond-expression* **`;`** *loop-expression* **`)`**\
16+
>     _statement_**`;`**
1717
1818
## Remarks
1919

@@ -93,9 +93,9 @@ for (int i = 10; i > 0; i--) {
9393
9494
A **for** loop terminates when a [break](../cpp/break-statement-cpp.md), [return](../cpp/return-statement-cpp.md), or [goto](../cpp/goto-statement-cpp.md) (to a labeled statement outside the **for** loop) within `statement` is executed. A [continue](../cpp/continue-statement-cpp.md) statement in a **for** loop terminates only the current iteration.
9595
96-
If `cond-expression` is omitted, it is considered true and the **for** loop will not terminate without a **break**, **return**, or **goto** within `statement`.
96+
If `cond-expression` is omitted, it's considered `true`, and the **for** loop won't terminate without a **break**, **return**, or **goto** within `statement`.
9797
98-
Although the three fields of the **for** statement are normally used for initialization, testing for termination, and incrementing, they are not restricted to these uses. For example, the following code prints the numbers 0 through 4. In this case, `statement` is the null statement:
98+
Although the three fields of the **for** statement are normally used for initialization, testing for termination, and incrementing, they're not restricted to these uses. For example, the following code prints the numbers 0 through 4. In this case, `statement` is the null statement:
9999
100100
```cpp
101101
#include <iostream>
@@ -125,7 +125,7 @@ By default, under [/Ze](../build/reference/za-ze-disable-language-extensions.md)
125125

126126
[/Zc:forScope](../build/reference/zc-forscope-force-conformance-in-for-loop-scope.md) enables standard behavior of variables declared in for loops without needing to specify `/Za`.
127127

128-
It is also possible to use the scoping differences of the **for** loop to redeclare variables under `/Ze` as follows:
128+
It's also possible to use the scoping differences of the **for** loop to redeclare variables under `/Ze` as follows:
129129

130130
```cpp
131131
// for_statement5.cpp
@@ -137,7 +137,7 @@ int main(){
137137
}
138138
```
139139

140-
This more closely mimics the standard behavior of a variable declared in a **for** loop, which requires variables declared in a **for** loop to go out of scope after the loop is done. When a variable is declared in a **for** loop, the compiler internally promotes it to a local variable in the **for** loop's enclosing scope even if there is already a local variable with the same name.
140+
This behavior more closely mimics the standard behavior of a variable declared in a **for** loop, which requires variables declared in a **for** loop to go out of scope after the loop is done. When a variable is declared in a **for** loop, the compiler internally promotes it to a local variable in the **for** loop's enclosing scope. It's promoted even if there's already a local variable with the same name.
141141

142142
## See also
143143

0 commit comments

Comments
 (0)