开发者

while(true) versus for(;;) [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicates:

Is “for(;;)” faster than “while (TRUE)”? If not, why do people use it?

for ( ; ; ) or while ( true ) - Which is t开发者_JAVA百科he Correct C# Infinite Loop?

Is there any appreciable difference between while(true) (or while(1)) and for(;;)? Would there be any reason to choose one over the other?


With optimizations enabled, they will compile identically.

You should use whichever one you find more readable.


No. I think for(;;) looks nicer. But they're the same.

Also see Is "for(;;)" faster than "while (TRUE)"? If not, why do people use it?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜