??? 10/22/10 09:07 Read: times |
#179268 - Corrigendum Responding to: ???'s previous message |
Jan Waclawek said:
Andy Neil said:
A for loop always take the value of the 3rd (sic) expression as the condition on whether to exit or continue the loop: if the value of the 3rd (sic) expression is zero, the loop exits; otherwise, it continues. Please replace 2nd for 3rd in the above sentence. D'oh! You are right - I have now corrected that (with a note) From the 'C' standard: ISO/IEC 9899:1990 (The 'C' standard) said:
6.6.5.3 The for statement Except for the behavior of a continue statement in the loop body, the statement for ( expression-1 ; expression-2 ; expression-3 ) statement and the sequence of statements expression-1 ; while( expression-2 ) { statement expression-3 ; } are equivalent. The 'C' standard goes on to say, Both expression-1 and expression-3 may be omitted. Each is evaluated as a void expression.
An omitted expression-2 is replaced by a nonzero constant. hence: for( ;; ) is equivalnt to: while( 1 ) |