为什么for循环使用分号? [英] Why does the for loop use a semicolon?
本文介绍了为什么for循环使用分号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在大多数C衍生语言(C,Java,Javascript等)中, for
循环具有相同的基本语法
In most C-derived languages (C, Java, Javascript, etc), the for
loop is of the same basic syntax
for (int i = 0; i < 100; i++) {
// code here
}
通常在行尾保留分号时,为什么此语法包含分号?另外,为什么在 i ++
之后没有分号?
Why does this syntax contain semicolons, when semicolons are usually reserved for the end of the line? Also, why is there no semicolon after i++
?
推荐答案
此伪代码:
for (A; B; C) {
D;
}
可以在内部转换为
{ // scope bracket
A;
while (B) {
D;
C;
}
}
这篇关于为什么for循环使用分号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文