考虑以下代码:
const char *s = "a b c d !";
const char *p = s;
top:for(; *p; p++) {
switch(*p) {
case 0x20:
case '\n':
goto top;
default:
putchar(*p);
}
}
有人可以解释为什么它进入无限循环而不是在何时*p停止NULL?我想到了以下几点:when *pis 0x20or \ngo to the beginning of the loop again,因为它测试条件并评估表达式p++。所以,我看不出它无限循环的理由,或者我真的不明白 C 编程语言中的goto语句和labels工作方式。