C中的'do'关键字

Sha*_*ash 3 c keyword

do是C中的关键字,我所看到的只是它用于while.所以我的问题是可以do单独使用while.

如果有,怎么样?

bit*_*ask 11

不,它不能.

更确切地说,这就是C标准所说的:

6.8.5迭代语句

句法

迭代语句:

while ( expression ) statement
do statement while ( expression ) ;
for ( expressionopt ; expressionopt ; expressionopt ) statement
for ( declaration expressionopt ; expressionopt ) statement

  • 读者注意:如果看起来`declaration`和`expressionopt`之间缺少分号,那是因为分号实际上是`declaration`的一部分. (3认同)