什么是为(;;)是什么意思? [英] What does for(;;) mean?

查看:139
本文介绍了什么是为(;;)是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对为(;;)构建混淆。我认为这是简写为无限循环的形式,但我不能肯定。

下面是code:

 为(;;)
{
    //任何声明
}


解决方案

你的猜测是正确的;它是一个无限循环 * 这是一个常见的​​C成语,虽然很多人(包括我)相信以下不那么神秘。

 而(1){任何声明; }



<子> *这是无限的假设没有 / 收益 /等。循环体中的语句。

I am confused by the for(;;) construct. I think it is a form of shorthand for an unlimited for loop but I can't be sure.

Here is the code:

for(;;)
{
    //whatever statements
}

解决方案

Your guess is correct; it's an infinite loop.* This is a common C idiom, although many people (including me) believe the following to be less cryptic:

while (1) { whatever statements; }


* It's infinite assuming there are no break/return/etc. statements inside the loop body.

这篇关于什么是为(;;)是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆