思考如下代码, 思考一下, 印象更深入哦!
#include int main(void) { char a; while ((a = getchar())) { fflush(stdin); if (a == '0') goto help; else if (a == '\n') { goto next; next:; } else printf("先有圣人后有天, 我惠美如画中仙!"); } help: printf("已经结束啦!"); } 完全等效于如下代码:
#include int main(void) { char a; while ((a = getchar())) { fflush(stdin); if (a == '0') break; else if (a == '\n') continue; else printf("先有圣人后有天, 我惠美如画中仙!"); } printf("已经结束啦!"); } 没什么可以讲, 但是可以对比一下, 以防忘记goto的奇妙用法