
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
2.6.4 顺序结构语句
1.GOTO语句
GOTO语句无条件地跳转到一个标号所在的位置,将控制权交给带有标号的语句或程序块。标号的定义在一个程序块中必须是唯一的。GOTO语句的语法格式如下:

【例2-43】GOTO语句举例。

为了保证GOTO语句的使用不会引起程序的混乱,GOTO语句的使用有下列限制。
(1)GOTO语句不能跳入IF语句、循环语句或下层程序块中。
(2)GOTO程序不能从一个异常处理器跳回当前块,但是可以跳转到包含当前块的上层程序块。
例2-44~例2-46是一些错误的GOTO语句举例。
【例2-44】GOTO语句企图跳入一个IF语句举例。

【例2-45】GOTO语句企图从IF语句的一个子句跳入另一个子句举例。


【例2-46】GOTO语句企图跳入一个下层程序块举例。

2.NULL语句
NULL语句不做任何事情,只用于保证语法的正确性,或者增加程序的可读性。
【例2-47】NULL语句举例。
