Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

C6296

warning C6296: Ill-defined for-loop: Loop body only executed once

This warning indicates that a for-loop might not function as intended. When the index is unsigned and a loop counts down from zero, its body is run only once.

The following code generates this warning:

void f( )
{
   unsigned int i;

   for (i = 0; i < 100; i--)
   {
      // code ...
   }
}

To correct this warning, use the following code:

void f( )
{
   unsigned int i;

   for (i = 0; i < 100; i++)
   {
      // code ...
   }
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.