|
|
|
|
|
by pmontra
3692 days ago
|
|
It doesn't apply to that sample code but maybe this is generally safer: for (pos = 0; !found || pos < limit; pos++)
but there is nothing wrong in using an iterator and break out of the loop, especially if the language or the library gives you iterators. |
|
When you are over the iteration limit you want to trigger True && False which is False to break out of the loop where the right side False is the condition when pos > limit
Btw this is covered in Code Complete Second Edition by Microsoft Press on page 378-380