Why the output is the same after I change longjmp(kansas, 47) to longjmp( kansas, 0)? The code should not go to "else" becasue the return value is 0 for longjmp(kansas, 0). #include #include using namespace std; class Rainbow { public: Rainbow() { cout << "Rainbow()" << endl; } ~Rainbow() { cout << "~Rainbow()" << endl; } }; jmp_buf kansas; void oz() { Rainbow rb; for(int i = 0; i < 3; i++) cout << "there's no place like home" << endl; longjmp(kansas, 47); } int main
不看手册? DESCRIPTION longjmp() and setjmp(3) are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program. longjmp() restores the environment saved by the last call of setjmp(3) with the corresponding env argu- ment. After longjmp() is completed, program execution continues as if the corresponding call of setjmp(3) had just returned the value val. longjmp() cannot cause 0 to
【在 n**d 的大作中提到】 : Why the output is the same after I change longjmp(kansas, 47) to longjmp( : kansas, 0)? The code should not go to "else" becasue the return value is 0 : for longjmp(kansas, 0). : #include : #include : using namespace std; : class Rainbow { : public: : Rainbow() { cout << "Rainbow()" << endl; } : ~Rainbow() { cout << "~Rainbow()" << endl; }