Tuesday, November 30, 2010

Infinite Loop

The following is an infinite loop:

for (unsigned int i = 10; i < 0 ;--i) { printf("%d",i); }

The test part can never be false, because i can never become negative. This problem occurs more often, when the declation of i is farther from the loop.

No comments:

Post a Comment