The archetypal 'for' loop is of course
for (i = 0; i < n; i++)
do_something_with_i;
where i runs from 0 to n - 1. It's particularly useful for
processing arrays. But 'for' loops can be perverted to do
just about anything loopwise. The question should be, is it
clear to someone reading the code what's supposed to be
happening? If not, a different construct might be better.
You can make an infinite loop using for ( ; ; ) and this is
a common C idiom, but it's exactly equivalent to while (1).
Take your pick.
BTW, can anyone explain why the 'for' syntax has only two
semicolons, not three? (I think this might have been the
intention of the original question.) In C the semicolon is a
statement terminator, not a statement separator (as in
Pascal). It would seem more intuitive to write
for (i = 0; i < n; i++;)
If an expression separator were needed a colon could have
been used, as with the '?' operator:
for (i = 0 : i < n : i++)
Just wondering.