Collect:
1\ int to LPCTSTR
In fact, LPCTSTR can be directly replaced with CString without type cast
CString str;
int number=15;
Str= "str"
. Format (_t ("%d"), number);
Str= "15" (preceded by two spaces; 4 indicates that 4 digits will be occupied, and if the number exceeds 4, it will output all numbers and will not truncate)
str. Format (_t ("%4d"), number);
Str= "0015" (. 4 indicates that 4 bits will be occupied, and if the number exceeds 4 digits will output all digits, not truncate)
str. Format (_t ("%.4d"), number);
A long conversion to CString is similar to the above, with the need to change%d to%ld.
The format description always starts with a% character, and the following is a description of the format of different types of data:
D Output signed decimal number
o Output unsigned octal number
x output unsigned hexadecimal number
U Output unsigned number
C Output Single character
s output a string of characters
F Output Real number (6 decimal digits)
e outputting real numbers in exponential form
G Choose the format of F and e format with smaller output width, no output 0
LD input-Output Long data
LF input and output double type data
M data output width is M
. n Outputs a decimal number of n
The above mentioned is the entire content of this article, I hope you can enjoy.