It's probably duplicated, but I did not find it here in SOpt, and I do not know how to search on Google.
How does the for
loop work in this syntax?
for(;;)
{
//...
}
It's probably duplicated, but I did not find it here in SOpt, and I do not know how to search on Google.
How does the for
loop work in this syntax?
for(;;)
{
//...
}
In this specific form is an loop infinity. It will only stop when you have break
.
The structure of a for loop in most mainstream languages is as follows:
for(inicializacao; condicao; pós loop)
Where:
inicializacao
: is a statement run only once - before the first loop. It's like a " pre-for ";
condicao
is a statement run before each loop and it will define whether the next loop will be executed or not. It's like the "stop condition" of the repetitions, as soon as this statement returns% with the reps ending. Any of these options can be omitted, ie empty statements . In this case, statement will do exactly what you want: nothing .