Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

use of for(;;) ?

 
Prashanth Naidu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,
i dont understand what the use of a for loop in the following fashion:
for(; {....}
please clarify my doubt.. thank you
-P-
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean with empty slots inside the parentheses? That's a "forever" loop. If there's nothing in there, then there'e no exit condition, and so the loop goes forever.
Personally I prefer to write this as "while (true)", but "for (;;)" is OK too.
 
Jeffrey Spaulding
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to the previous posting.
I use this form ( i also prefer while( true ) { ... } ) when i can
have many different reasons to leave a loop with
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic