Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the function of VC++ to convert numbers into strings?
What is the function of VC++ to convert numbers into strings?
You can use the Format () method of the CString class, which is implemented as follows:

int i = 2008

CString string;

Strait. Format ("%d", i);

It doesn't matter.

Functional analysis:

CString:: format

Void format (LPCTSTR lpszFormat, ...);

Void format (UINT information id, ...);

parameter

A format control string.

NFormatID contains the string resource identifier of the format control string.

explain

This member function is used to write formatted data into CString, just as the sprintf function writes printed format data into a C-style character array. This member function formats and stores a series of characters and values in CString. Convert and output each optional parameter (if any) in the function according to the format specified in lpszFormat or the string resource identified by nFormatID.

When you pass a string as an optional parameter, you must explicitly convert it to LPCTSTR.