Possible Duplicate:
while (1) Vs. for (;;) Is there a speed difference?
Hi,
Which is better,faster and more optimized way to implement infinite loop - for(;;) or while(1)? and why?
I prefer for(;;)
because it doesn't test anything and semantically this is what you mean. It doesn't make so much sense to keep testing if 1 is true. However any professional C programmer should immediately recognize both idioms as both are used.
In terms of actual performance there should be no difference. The compiler will optimize away the test.
I tried testing both to see which is faster but neither of them has completed yet.
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