[C]goto statement, rarely been used. Deprecated???
#include <stdio.h> int main() { int a = 0; while (a < 10){ printf("a is %d\n", a); if ( a == 5) goto OUT; a++; } OUT: printf("We're out of the loop.\n"); return 0; }
运行结果为:
a is 0 a is 1 a is 2 a is 3 a is 4 a is 5 We're out of the loop.