Using a for loop without its typical structure (initialization, condition, increment) can be confusing. In those cases, it is better
to use a while loop as it is more readable.
The initializer section should contain a variable declaration to be considered as a valid initialization.
Replace the for loop with a while loop.
for (;condition;) // Noncompliant; both the initializer and increment sections are missing
{
// Do something
}
while (condition)
{
// Do something
}
int i;
for (i = 0; i < 10;) // Noncompliant; the initializer section should contain a variable declaration
{
// Do something
i++;
}
int i = 0;
while (i < 10)
{
// Do something
i++;
}
for
statement