#include <stdio.h>

int function(void) {
    static int i, state = 0;
    switch (state) {
        case 0: goto LABEL0;
        case 1: goto LABEL1;
    }
    LABEL0: /* start of function */
    for (i = 0; i < 10; i++) {
        state = 1; /* so we will come back to LABEL1 */
        return i;
        LABEL1:; /* resume control straight after the return */
    }
}

int main(){
  printf(":%d\n" , function());
  printf(":%d\n" , function());
  printf(":%d\n" , function());
  printf(":%d\n" , function());
  printf(":%d\n" , function());
  return 0;
}

想过,但是没想到,还真有啊!

相关文章:

  • 2021-04-28
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-09-10
  • 2021-08-23
猜你喜欢
  • 2022-12-23
  • 2021-11-18
  • 2021-08-12
  • 2021-09-26
  • 2021-04-24
  • 2021-07-31
  • 2022-01-17
相关资源
相似解决方案