SA> for (count=1; count!=6; count++)
RS> Using a test for absolute equality or inequality for the test
RS> portion of a loop is not a good idea. It's safer to always use
RS> a test for "less than" or "less than or equal to" or the
RS> flip side of "greater than" or "greater than or equal to".
Actually, testing for "absolute" equality/inequality is exactly what the C++
standard template library uses for its iterators.
When using non-integral types (float, double, long double), you cannot use
absolute equality. When using integral types (everything else), you can.
When iterating (pointers, usually), it's often a good idea. Sometimes it's
the ONLY idea (when iterating through, for example, linked lists?).
RS> It's not an idea I came up with. It's something that was passed
RS> on to me by people with many years experience. The idea is also
RS> backed up by countless examples in quality instructional text.
I realize this is the C_ECHO, not the C_PLUSPLUS echo, but these guys at HP
aren't exactly newbies. :-)
However, in this particular case, convention wins out, and count < 6 should
be used. :-)
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|