CSTRING under the MFC uses the following format (FORMAT)

xiaoxiao2021-03-06  115

When we are writing programs, the processing frequency of strings is quite high. For example, if the digital conversion is character, or the character is converted to integer, double-precision type, etc., if you can use the character string, it will play a half-time effect, which is nothing. According to MSDN explanation: Supports two conversion formats, Void Format (LPCTSTR LPSZFORMAT, ...) as shown below; parameter lpszformat is a format control string, Void format (uint nformatid, ...); where parameter nformatid is resource No., such as numbers in string resources. The function of calling this function is to be able to think of the Sprintf formatted conversion, such as the following example.

CString Str;

Str.Format (_T ("Floating Point:% .2F / N"), 12345.12345);

_tprintf ("% s", (lpctstr) STR);

Str.Format ("Left-Justified Integer:% .6D / N"), 35);

_tprintf ("% s", (lpctstr) STR);

Str.Format (IDS_SCORE, 5, 3);

_tprintf ("% s", (lpctstr) STR);

Where IDS_SCORE is a flag in the string resource. The content contained in "Penguins:% D / NFLYERS:% D / N" then the input of these two strings is: floating point: 12345.12

LEFT-JUSTIFIED INTEGER: 000035

Penguins: 5

Flyers: 3 So if you want to use a relatively universal string, you can define this string as the ID in the resource, which modifies will be more convenient and faster.

转载请注明原文地址:https://www.9cbs.com/read-101463.html

New Post(0)