File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -27,11 +27,10 @@ The following code generates this warning. This issue stems from the **`for`** l
27
27
int buff[14 ]; // array of 0..13 elements
28
28
void f ()
29
29
{
30
- for (int i=0; i<=14;i++) // i exceeds the index
31
- {
32
- buff[ i] = 0; // warning C6200
33
- // code...
34
- }
30
+ for (int i = 0; i <= 14; i++) // i exceeds the index
31
+ {
32
+ buff[i] = 0; // warning C6200
33
+ }
35
34
}
36
35
```
37
36
@@ -41,10 +40,9 @@ To correct both warnings, use correct array size as shown in the following code:
41
40
int buff[14 ]; // array of 0..13 elements
42
41
void f ()
43
42
{
44
- for ( int i=0; i < 14; i++) // i = 13 on the final iteration
45
- {
46
- buff[ i] = 0; // initialize buffer
47
- // code...
48
- }
43
+ for (int i = 0; i < 14; i++) // i == 13 on the final iteration
44
+ {
45
+ buff[i]= 0; // initialize buffer
46
+ }
49
47
}
50
48
```
You can’t perform that action at this time.
0 commit comments