home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C03 / DynamicDebugFlags.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  876 b   |  32 lines

  1. //: C03:DynamicDebugFlags.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. #include <iostream>
  7. #include <string>
  8. using namespace std;
  9. // Debug flags aren't necessarily global:
  10. bool debug = false;
  11.  
  12. int main(int argc, char* argv[]) {
  13.   for(int i = 0; i < argc; i++)
  14.     if(string(argv[i]) == "--debug=on")
  15.       debug = true;
  16.   bool go = true;
  17.   while(go) {
  18.     if(debug) {
  19.       // Debugging code here
  20.       cout << "Debugger is now on!" << endl;
  21.     } else {
  22.       cout << "Debugger is now off." << endl;
  23.     }  
  24.     cout << "Turn debugger [on/off/quit]: ";
  25.     string reply;
  26.     cin >> reply;
  27.     if(reply == "on") debug = true; // Turn it on
  28.     if(reply == "off") debug = false; // Off
  29.     if(reply == "quit") break; // Out of 'while'
  30.   }
  31. } ///:~
  32.