Let's take a look at a piece of code. You can first guess what the output result is?
// Debugop. cpp
# Include <iostream>
# Include <string>
# Include <vector>
Using namespace STD;
Int main ()
{
# Ifdef debug
Cout <"beginning execution of main ()/n ";
# Endif
String word;
Vector <string> text;
While (CIN> word)
{
# Ifdef debug
Cout <"word read:" <word <"/N ";
# Endif
Text. push_back (Word );
}
}
I use Microsoft Cl compiler in windows.
D:/> Cl debugop. cpp
D:/> debugop
No beginning execution of main ()
Instead, wait for the user to enter the word
Many may want to see the appearance of beginning execution of main (). In this case, you need to understand the pre-processor indicator application.
If the compilation process is as follows:
D:/> Cl-ddebug debugop. cpp
D:/> debugop
The running result shows beginning execution of main ()
Then wait for the user to enter the word
This is the application of the debug Preprocessor indicator.