C语言中的setjmp与longjmp

  #include <stdio.h>
     #include <setjmp.h>
     jmp_buf buf;
 
    void banana() {
         printf("%s","in banana() \n");
         longjmp(buf,0);
         printf("%s","you will never see this \n");
     }
 
     int main() {
         if(setjmp(buf)) {
             printf("%s","back in main\n");
         }
         else {
             printf("%s","first time throught\n");
             banana();
         }
         getchar();
   }

你可能感兴趣的:(c,语言,include)