What does% 12.10lg mean in C ++ string formatting
I saw this piece of code in one of the C ++ projects in the Windows environment. just wondering what the meaning means %12.10lg
. Anyone have an idea?
class Point
{
double x, y;
public Point::Point(double x_cord, double y_cord)
{
x = x_cord;
y = y_cord;
}
}
void foo(){
Point ptStart(12.5, 33.5678)
TRACE("%12.10lg, %12.10lg, %12.10lg\n", ptStart)
}
source to share
To display messages from your program in the debugger output window, you can use the ATLTRACE macro or the MFC TRACE macro. Like assertions, trace macros are only active in the Debug version of your program and disappear when compiled in the Release version. Like printf, the TRACE macro can handle multiple arguments.
https://msdn.microsoft.com/en-us/library/4wyz8787(v=vs.80).aspx
In your specific case, it "%12.10lg"
is a string similar to what you see in printf .
printf uses this format:
%[flags][width][.precision][length]specifier
In your case:
flags = unused
width = 12
precision = 10
length=long int
specifier=short representation
When you print this, it will print the following arguments (ptStart)
source to share