In addition to scope issues and one more thing, these are:
for(<init>; <test>; <step>) { <body> }
matches with:
<init> while(<test>) { <body> <step> }
Like other people, just as you can have a while without a <init> or <step> form, you can have a for loop without them:
while(<test>) { <body> }
coincides with
for(;<test>;) { <body> } //Although this is terrible style
And finally, you may have
for(;true;) { <body> }
Now, remember when I said there is one more thing? This is because for loops do not need a test - this gives a solution that everyone else posted:
for(;;) { <body> }
source share