for(; true;)不同于while(true)? [英] for(;true;) different from while(true)?

查看:138
本文介绍了for(; true;)不同于while(true)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的理解是正确的,他们做同样的事情。为什么有人会使用for变体?它只是味道吗?

If my understanding is correct, they do exactly the same thing. Why would anyone use for the "for" variant? Is it just taste?

编辑:我想我也在想(for;;)。

I suppose I was also thinking of for (;;).

推荐答案

for (;;)

b
$ b

通常用于防止编译器警告:

is often used to prevent a compiler warning:

while(1)

while(true)

通常会引发一个关于条件表达式常量的编译器警告最高警告级别)。

usually throws a compiler warning about a conditional expression being constant (at least at the highest warning level).

这篇关于for(; true;)不同于while(true)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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