For(; ;)

how to use for(; ;)
and how to stop it with break;
1
2
for(;;)
  break;


i want an Example
The loop you described is really an endless loop. It has no condition with which it will terminate. This is usually done in video games, where the game runs a continuous loop until some condition breaks it and the game ends.

Is better to use this:

1
2
3
4
5
6
7
while(true)
{
//.... 

     if(Some_Condition)  //the user selects "quit" on the menu screen
       break;
}


Its better because its easier to read. But it accomplishes the same thing.
while(true) is the same as for(;;). It's personal preference, although I tend to lead towards the while(true) as well.
Topic archived. No new replies allowed.