#include <iostream> #include <cassert> using namespace std; int main() { int number = 0; cin >> number; assert(number == 0); cin >> number; assert(number == 0); system("pause"); return 0; }
不想讓視窗出現,就在cassert函式庫上面加上
#define NDEBUG #include <cassert>
#include <iostream> #define NDEBUG #include <cassert> using namespace std; int main() { int number = 0; cin >> number; assert(number == 0); cin >> number; assert(number == 0); system("pause"); return 0; }