更新时间:2023-01-18 22:00:12
是的,这是一个无限循环。这是一个普通的,没有条件表达式循环。
从的为文档
:
所有表达式for语句都是可选的;例如,下面的语句是用来写一个无限循环:
为(;)
{
// ...
}
块引用>I've been looking through some sample source code for an application I use and I came across this line:
for (;;) { // The rest of the application's code }
It looks like this is to create an infinite loop, but I'm not familiar with ";;" and it's very hard to Google unfortunately.
Yes, that is an infinite loop. It's an ordinary for loop with no condition expression.
From the documentation for
for
:All of the expressions of the for statement are optional; for example, the following statement is used to write an infinite loop:
for (; ; ) { // ... }