debug2.cpp

来自「Thinking in C++ 2nd edition source code 」· C++ 代码 · 共 31 行

CPP
31
字号
//: C03:Debug2.cpp
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Framework for writing debug code
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
#define DEBUG

int main(int argc, char * argv[]) {
  int debug = 0;
  if(argc > 1) { // If more than one argument
    if (*argv[1] == 'd')
      debug++; // Set the debug flag
    else {
      cout << "usage: debug2   OR   debug2 d" << endl;
        "optional flag turns debugger on.";
      exit(1);  // Quit program
    }
  }
  // ....
#ifdef DEBUG
  if(debug)
    cout << "debugger on" << endl;
#endif // DEBUG
  // ...
} ///:~

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?