次の方法で共有


C6296

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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.

Example

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 ...  
   }  
}