There are a lots of option available for infinite loop but this are mostly use while(true) or for(;;)
I know while(true)
is the best option, since it is easier to understand.
But I want to use for(;;)
.
I want to know what is going on inside of for loop
when I we used two ;
within for loop.
for(;;)
Semicolon means its an empty statement. But how its works when we use inside of for loop
for infinite execution?
This is what happens:
for (initialization statement; condition check; increment/decrement)
// loop body;
With for(;;)
:
Therefore it will run forever, exactly like while(true)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With