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)
}

      

+3


source to share


2 answers


TRACE

Probably uses specifiers normal format, which means that %12.10lg

should print the value of double

a minimum width of 12 and an accuracy of 10, something like: 15.8930000000

.



+4


source


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)

+2


source







All Articles