Dev-C下无法阻止assert让窗口闪灭了!C/C++ code#includeiostream#includeassert.h#includewindows.h
Dev-C下无法阻止assert让窗口闪灭了!
- C/C++ code
#include<iostream>#include<assert.h>#include<windows.h>#include<stdlib.h>#include<stdio.h>using namespace std;int test(int a,int b){ cout<<"acd"<<endl; if(a+b>6) { assert(!"Should never get here!"); system("pause"); return -1; } return a+b; }int main(){ int m=test(6,1); cout<<"m = "<<m; //test(1,2); getchar(); system("pause"); return 0;}跟assert有关,但不知道为什么。
闪灭,你懂得。
[解决办法]
断言失败,灭了不正常吗?
[解决办法]
[解决办法]
assert一般用于debug版本 抓一些你认为不会出现的问题. 好处是弹出框后可以直接调试.
默认好像内部会调用exit 可以通过设置 让他不调用exit. 你可以跟进去看看就知道设置什么可以让他不退出了.
