Str. Format ("Formatting control string", output list);
The format control string consists of a format string and a non-formatted string enclosed in double quotation marks. Where the non-format string is output as-is.
A format string is a string that begins with a%:%[identifier [output min width] [precision] conversion specifier.
Common conversion specifiers: D, integral type, f, floating point, double precision, E, exponential output, double precision, s, output string, parameter char* pointer, etc.
[] can be omitted within.
The logo has-, +:-Indicates left alignment, right fill, and vice versa.
Outputs the minimum width, expressed in decimal integers.
The precision, beginning with the. Number, followed by a decimal integer. The meaning is that if the output is a number, the number of decimal places, or if the output is a character, the number of characters in the output.
With the _ttof () function, you need to include the Stdlib.h file to convert the CString type to floating-point data.
1 double PI =3.14159;
2 CString s;
3 S.format (" output with fractional form:%.2f", pi);//So, the value of pi is stored in S, it's character type.
4 PPI = _ttof ((LPCSTR) s);//So, we keep pi=3.14159 to two decimal places.
MFC uses the CString and format member functions to format the output of a number