Debug mark
Applicable preprocessing #define defines one or more debug marks, and manages the debugging section in the code. When the program finally debugged, just use the #undef tag, the debug code will disappear. Commonly used debug markers are Debug, statement sequence:
#define debug
#ifdef debug
Debug code
#ENDIF
2. Debug tag during operation
Turn the debug mark on and off during the program. It can be implemented by setting a debug BOOL tag. This is more convenient to run the command line.
Such as the following code
#include
#include
Using namespace std;
Bool debug = false;
Int main (int Argc, char * argv [])
{
For (int i = 0; i IF (String (Argv [i]) == "- debug = on") Debug = True; BOOL Go = TRUE; While (Go) { IF (debug) { Debug code } else {} } } 3. Convert variables and expressions into strings However, using a string operator to implement the conversion output definition #define pr (x) cout << # x "=" << x << '/ n' 4.C language assert () This macro is in #include Using namsapce std; int main () { INT i = 100; Assert (i! = 100); // fails } Add #define nDebug before #include }