void goto_catch()
{
int i =2;
try {
i = i / 0;
}
catch (...)
{
goto tiao;
}
tiao:
cout << "ok" << endl;
}
我在手机上编译就能打印ok,vs上就中断了,所以这代码对吗?怎么设置才能让vs执行该命令呢?
void goto_catch()
{
int i =2;
try {
i = i / 0;
}
catch (...)
{
goto tiao;
}
tiao:
cout << "ok" << endl;
}
我在手机上编译就能打印ok,vs上就中断了,所以这代码对吗?怎么设置才能让vs执行该命令呢?
#include<iostream>
#include<signal.h>
#include <setjmp.h>
using namespace std;
jmp_buf registers;
void handler(int)
{
longjmp(registers,1);
}
int main(void){
signal(SIGFPE,handler);
int i = 2 , b = 0;
if(1 == setjmp(registers))
{
goto tiao;
}
i = i / b;
tiao:
cout << "ok" << endl;
}