Trace macro for the VC under the program debugging is very useful things, with a similar function of printf, the macro is only in the debug version of the program appears, when the release of the macro is complete message, thus helping you to adjust the release also reduce the amount of code.
The use is very simple and the format is as follows:
TRACE ("ddddddddddd");
TRACE ("wewe%d", 333);
There are also trace0,trace1,trace2 ... correspond to 0,1,2 respectively. A parameter
The trace information is output to the Output window of the VC IDE environment (which is the window you are prompted to compile the project error), but only to the program you are running your debug version of in the VC.
Trace information can also be captured using DebugView. In this case, you can not run your program in the VC IDE environment, and the build good debug version of the program run alone, this time in the DebugView window to see the output of the Debugvie format.
The use of trace in VC has the following four kinds:
1.
TRACE, which is a C-like printf ("output string") without a dynamic parameter output string;
2.
The string in TRACE can be output with a parameter, like C's printf ("...%d", variable);
3.
TRACE can take two parameter outputs, such as C's printf ("...%d...%f", variable 1, variable 2);
4.
TRACE can take three parameter outputs, such as C's printf ("...%d,%d,%d", variable 1, variable 2, variable 3);
TRACE macros are a bit like the printf function we used in C, which allows the program to output some debugging information during the run, so that we can understand some of the state of the program. But there's a difference:
The TRACE macro is output only in the debug state, and the previously used printf function has output in all cases. Like the printf function, the trace function can accept multiple parameters such as:
int x = 1;
int y = 16;
float z = 32.0;
Trace ("This is a TRACE statement/n");
TRACE ("The value of X is%d/n", x);
TRACE ("x =%d and y =%d/n", x, y);
TRACE ("x =%d and y =%x and z =%f/n", x, Y, z);
Note that the trace macro only works on the debug version of the project, and the trace macro is ignored in the release version of the project.