<分区>
Possible Duplicate:
Is “for(;;)” faster than “while (TRUE)”? If not, why do people use it?
我想知道 for(;;)
和 while(1)
执行相同功能时有什么区别?编译速度会有什么不同
标签 c++ infinite-loop
<分区>
Possible Duplicate:
Is “for(;;)” faster than “while (TRUE)”? If not, why do people use it?
我想知道 for(;;)
和 while(1)
执行相同功能时有什么区别?编译速度会有什么不同
最佳答案
它们的不同之处在于,许多编译器会警告 while(true)
(“用作循环表达式的常量表达式”),而据我所知,没有人会警告 for(;; )
。
不过,它们应该生成相同的代码。
关于c++ - for(;;) 和 while(1) 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4352421/